.mlv and .mat files
Hi,
I am running a code in a Mathscript node and saving some variables at the end of the execution in a file (.mlv).
I understand that these file format is exclusive to Mathscript, but is there someway I can convert this to a .mat file so that it can be stored in a database and used with MATLAB later whenever needed?
Any help or suggestions are appreciated.
Thanks,
Chintan
Hi Grant,
Thanks for your reply.
I have tried the data analysis offline. While saving it in .mlv it saves all the variables perfectly. I tried using csvwrite and dlmwrite as well, but they just write random number instead of the variables I specify in the syntax.
Here is the code I am using. The saving part at the bottom is what is bugging me. Everything else works fine. Please suggest another way to do this.
Thanks,
Chintan
data=-load(dataf); %load decay data
head=load(headf); %load header
laser = load(laserf);
data_length=length(data);
mode=head(1); %Single=0, Multi=1, Filter=2
tres=head(2)*10^9; %resolution in ns
switch mode
case 0
lamb_num=1;
lambdas=head(12); %lambda summary
lambda_vec=head(13+lamb_num:end); %vector with wavelengths
dec_num=head(10);
rep_num=head(11);
flag=0;
case 1
Wini=head(9); %first wavelength (nm)
Wend=head(10); %final wavelength (nm)
Wstp=head(8) ; %steps (nm)
lambdas=[Wini Wstp Wend]; %lambda summary
lambda_vec= head(14:end-1); %vector with wavelengths
lamb_num=head(11)/head(12); %number of wavelengths measured
dec_num=head(11);
Wini=head(9); %first wavelength (nm)
Wend=head(10); %final wavelength (nm)
Wstp=head(8) ; %steps (nm)
rep_num=head(12);
gain = head(7);
flag=0;
case 2
dec_num=head(9);
rep_num=head(7);
filter_wheel_pos=head(8);
center_wavelenghts=head(13:end);
flag=1;
end
lim=[30/tres 100/tres];
trspec=data(lim(1):lim(2),; %truncate data
laser=laser(lim(1):lim(2),;
trspec=trspec-ones(lim(2)-lim(1)+1,1)*mean(trspec(1:2/tres,); %detrend (substract mean of first 2 ns)
time_vec=[0:lim(2)-lim(1)]*tres;
stspec=trapz(trspec);
if flag==0
save('Processed','mode','tres','dec_num','rep_num','lambda_vec','lambdas','trspec','stspec','time_vec','gain','laser');
end
if flag == 1
save('Processed','mode','tres','dec_num','rep_num','trspec','stspec','time_vec','filter_wheel_pos','center_wavelenghts','fwhm');
end
Similar Messages
-
Read waveform file from .mat file and perform filtering
I have a sample waveform stored in matlab (.mat) and would like to perform various filtering after reading it. I am able to read and view the the waveform on a Waveform graph, but unable to do any filtering.
Can somebody help suggest a way to read the .mat file, perform low pass filtering and display it on a graph ?Hi Lynn,
Attached is the vi and the sample data .mat file.
regards,
Prakash
Attachments:
Read MATLAB File.vi 58 KB
sigcor1.zip 178 KB -
How to open a .MAT file in LABVIEW
Hey everyone,
I currently have a .MAT image file which I would like to open in LABVIEW to apply some image filters. However, I am unsure as to how to open the .MAT file in LABVIEW. Ideally I would like to be able to open the .MAT file without using matlab, and it seems the only way to accomplish this task is through the mathscript node. I have attached an example of the image im trying to open, as well as the LABVIEW program which I would like to use on the image. Thanks for the feedback! =]
Attachments:
MAT_Image_Adjust.zip 1779 KBHi Boiler,
1) Do you have a choice in the format you export your data from MATLAB?
"ASCII Format
Complete the following steps if you want to import or export data between LabVIEW and the MATLAB® environment, the process is straightforward as long as you are using ASCII format.
From the MATLAB® environment to LabVIEW
To save a vector or a matrix Xin ASCII format with tab delimiter, enter the following in the command window or m-script file in the MATLAB® environment:
>>SAVE filename X -ascii -double -tabs
This creates a file whose name is filename, and it contains the data X in ASCII format with a tab delimiter.
Import the file into LabVIEW using the Read From Spreadsheet File VI located on the Programming»File I/O palette.
2) Have you tried using the mathscript node? Did you get any errors?
"Binary Format
Complete the following steps if you want to import or export data between LabVIEW and MATLAB®.
From the MATLAB® environment to LabVIEW
To read a .mat file in LabVIEW would require a VI to parse the file. This may be easier if each variable is saved to a separate file.
" -- this was done here, no ideas if it still works,
I want to read a Matlab MAT file into labview
Hope this helps, James
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! -
How to implement reading data from a mat file on a cRIO?
Hi all!
I am not even sure, this is plausible, but I'd rather ask before i start complicating. So far, I have not found any helpful info about reading in data to a RT device from a file (kind of a simulation test - the data is simulated).
I have the MatLab plugin that allows the data storage read a MAT file, which has a number of colums representing different signals and lines representing the samples at a given time (based on the sample time - each sample time has it's own line of signal data).
I have no idea of how to implement this to cRIO.
The idea is:
I have some algorithms that run on the RIO controller in a timed loop. As the inputs to these algorithms, i would need to acces each of the columns values in the line, that corresponds to the sample time (kind of a time series - without the actual times written).
I am fairly new to RT and LV development, so any help would be much appreciated.
Thanks,
Luka
Solved!
Go to Solution.Hi Luka!
MAT file support in LabVIEW is handled by DataPlugins. Here you can find the MATLAb plugin:
http://zone.ni.com/devzone/cda/epd/p/id/4178
And here you can find information on how to use DataPlugins to read or write files of a certain format:
http://www.ni.com/white-paper/11951/en
There is also an open-source project that addresses the problem, you can find it at
http://matio-labview.sourceforge.net/
Unfortunately, RT systems are not supported by DataPlugins, so fist you'll have to write a VI on the Host computer to convert your files to a usable format (I suggest TMDS for compactness and ease of use), and the work on the converted files in the cRIO VI. If you have other questions about DataPlugins or anything else, please get back to me.
Best regards:
Andrew Valko
National Instruments
Andrew Valko
National Instruments Hungary -
So, I search the binary matlab file format('*.mat').
Title:
Moving Data Between MATLAB® and LabVIEW
Problem:
How can I share data between LabVIEW and the MATLAB environment?
Solution:
MATLAB users can move data between the
MATLAB environment and LabVIEW, you have several options. Prior to
LabVIEW 5.1, the only way to transfer data between these two
environments was to use the Save and Load functions. Those are discussed herein.
Beginning
in LabVIEW 8.0, MathScipt was introduced. MathScript is an integrated
part of LabVIEW that you can use to combine intuitive graphical
dataflow programming with math-oriented textual programming. See the
attached links below for more information on MathScript.
Beginning
in LabVIEW 5.1, the MATLAB script node was introduced into the LabVIEW
programming environment. The MATLAB script node makes ActiveX calls to
the MATLAB software from within LabVIEW. This requires that both MATLAB
be installed on the same machine and that a valid license is obtained.
More information on the MATLAB script node can be found in the attached
KB's.
For all versions of LabVIEW, this data transfer can be
performed by saving the data in a file using the MATLAB software and
reading it directly from LabVIEW, or vice versa. In the MATLAB
environment, the command "save" allows you to save the data in
binary format (*.mat) or ASCII format. You also have an option of
saving it in ASCII format using a tab delimiter between data points and
the command "load" allows you to read in the data.
ASCII Format
Complete the following steps to import or export data between LabVIEW and the MATLAB environment using an ASCII file format.
From the MATLAB environment to LabVIEW
To save a vector or a matrix X in tab-delimited ASCII format, enter the following in the command window or m-script file in the MATLAB environment:
>>SAVE filename X -ascii -double -tabs
This creates a file named filename containing data X in tab-delimited ASCII format.
Import the file into LabVIEW using the Read From Spreadsheet File VI located on the Functions»File I/O palette.
From LabVIEW to the MATLAB environment
To export a matrix X from LabVIEW to the MATLAB environment, first save the data in ASCII format in LabVIEW using the Write To Spreadsheet File VI on the Functions » File I/O palette.
Enter the following in the command window of the MATLAB environment, or in the m-script file:
>> LOAD filename
This reads the data into the MATLAB environment.
Binary Format
Complete the following steps to import or export data between LabVIEW and the MATLAB environment.
From the MATLAB environment to LabVIEW
As mentioned above, LabVIEW does not save multiple variables to one
data with extra manipulation, and will not be discussed here.
Therefore, the only way of sending the data from the MATLAB environment
to LabVIEW without tampering with the MAT binary file structure is
using the ASCII format. Also, please bear in mind that you need to have
one file for one variable.
From LabVIEW to the MATLAB environment
Because
the MATLAB software saves data in its own binary format, the "MAT"
file, binary LabVIEW data must be converted to this format prior to
transferring the data. The attached examples can be used to save
LabVIEW data in the MATLAB software format. The convenience of the .MAT
file format is that more than one variable can be saved in the same
file. The example shows saving seven variables to .MAT format; the
example can be modified for any number of variables.
Once this data is saved from LabVIEW, it can be read into the MATLAB environment, using the following command:
>>LOAD filename
The Who
command can then be used to display all the seven variable names, and
you can display the content of them by entering the variable names at
the command prompt as usual.
MATLAB® is a
registered trademark of The MathWorks, Inc. Other product and company
names listed are trademarks and trade names of their respective
companies.
| Michael K | Project Manager | LabVIEW R&D | National Instruments | -
Creating .mat files with Matlab dataplugin in LabVIEW
I am trying to create a .mat file in LabVIEW using the Matlab dataplugin. It appears to create a group called "Vector" without being told to, and it also concatenates group and channel names together. I have made an example to demonstrate this behaviour. I am trying to create a group called "Group" and inside it a channel called "Channel". What I get looks like a group called "Vector" and inside it a channel called "GroupChannel". What am I doing wrong?
Best Regards,
John Sackett
Solved!
Go to Solution.
Attachments:
write mat example.zip 54 KBHello John
Thank you for getting in touch regarding your issue. I am an applications engineer here at National Instruments, as I understand you are using the data plugin for Matlab within LabVIEW, but as shown with your code when you label the channel or group you get an outcome which you don't expect.
I have opened and had a look at your code and can see where the issue is arising. The functions you are using are normally used with TDM files, .MAT files are compatible but there are a few differences between the file formats, which is why you are getting the outcome we have seen. A TDM file has headers named channelgroup and channel, but Matlab does not have the channelgroup header in the file type and therefore the functions in LabVIEW merge the 2 strings to the available header.
I am not able to open your .MAT file so could you give me a brief description of what occurs inside Matlab?
Have you looked into using the script node to allow for .MAT file types in LabVIEW? Here is the help file
I have also found some resources which you may find useful.
LabVIEW to MATLAB
Convert file
Open .MAT in LAbVIEW
DataPlugin
Let me know if you would like any further information
Regards
Stephanie L
Applications Engineer
National Instruments UK and Ireland -
Help opening a .mat file
Hi,
I am new to labview and need some assistance trying to open a .mat file for further analysis (example file attached). The file formate is level 5 and I believe the data is in arrays. I do not have access to confirm the structure but have been told the layout of the data i need to access follows the following structure: MotionFile_walkaround -> Actor_50_human -> Segments -> Sacrum -> Pose.
I have successfully read the header and found that byte swapping is required. I have downloaded the Mat-File IO library but have had no success in reading the actual data set beyond the header but assume this is due to my inexperience with both .mat files and labview.
Any help would be greatly appreciated.
Attachments:
walkaround.zip 1527 KBHey doofus13,
When reading your .mat file, created in The MathWorks, Inc. MATLAB® software, I recommend using the MATLAB® DataPlugin found here:
MATLAB® DataPlugin
http://www.ni.com/example/29178/en/
Then, you can use the Data File Viewer function to view all of the data in your file. Any data that can be seen in the Data File Viewer can then be extracted using the Data Storage API. I looked through the file you provided and was able to view and extract the data contained in the file using the Data Storage API so it should work fine for you.
MATLAB® is a Registered Trademark of The MathWorks, Inc.
Hope this helps!
--Ryan_S. -
Saving Vector of BufferedImages to binary .mat file
Hi,
I have a matlab file that reads in Binary .mat files. These files are made up of sections of images.
I've used Java to create these sections and therefore need to save the vector of bufferedimages to a .mat binary file.
I've been using the
File file = new File("test.mat");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(patches); syntax but when I attempted to read the file into my matlab code I got the following error:
Unable to read MAT-file patches\test.mat: not a binary MAT-file.Does anyone know how to save as a binary .mat file?
Cheers
NI still can't find any sources of how to save a .mat
binary file in Java, unless I'm something glaringly
obvious on the page you posted (quite possible)
Most probably you are going to have to write lots of code to take your data and format it according to the 'mat' file specification. You might just be lucky an find code off the peg but I doubt it!
Be prepared for some late nights! -
CS 5.5 and .mts files
I've got two identical pc's. One pc image was ghosted from the other.
When I try to import some AVCHD .mts file from the ghosted machine, I get the error message. "The File has an unsupported compression type". The original machine imports them ok. Some import fine while others do not, and the files that fails opens fine in other programs such as after effects.
Ive deactivated, uninstalled, cleaned and reinstalled Production premium and get the same results. Adobe says it's activated.
Any ideas whats causing this?shooternz thanks for the reply..
From previous experience, media files contained in directories or folders with "strange syntax" never affected us Mac users. Adobe applications had always been able to opening them regardless. For argument sakes and to prove a point, I'll move some smaller files to the desktop and try re-opening them and enclose a screen grab of the errors encounteres.
Files stored on RAID Volume:
Same files copied to the desktop:
Just to prove this ain't something thats exclusive to my workstation, I've installed CS5.5 MC on my MacBook Pro.
Opening .mts file on the MacBook Pro with CS 5.5 installed:
Guess what? I still get the same annoying error. Do you folks still think it's a syntax issue??
I believe CS 5.5 doesn't support the compression type for one reason or another and that's soo annoying!!
Seems the only way I'm able to edit these files for the time being is to downgrade to CS5
FYI:
Those files were shot on a Canon ivis HF11 and PPro CS5 had no troubles opening them, no mater what the syntax. -
Hello,
For some reason I cannot open a matlab file. The file has been ftp'd and is called "Failed MAT file.zip"
I can open other .mat files just not this particular one. I am using DIadem 2012 SP1.
When I load the data into the data portal it says loading the file "file name" has failed for all the loading methods (DataPlugin) linked to this file type. No DataPlugin assigned for this type.
When I assign the plugin to open MatLab file I get another error stating it cannot open the file with the loader "MatLab"
Any ideas?
Thanks
TimHi Tim,
I downloaded your *.mat file and had the same error message you report. The DataPlugin does appear to correctly import 239 of the channels from that file. Do you know if the "EngTrqStatic1" is the only one it fails on, or was that channel supposed to be empty? I'll send your file on to R&D for them to see what's happening during the import. There are some *.mat file data types that the DataPlugin can't support (like custom structs), so it's possible we won't be able to help, but let's see.
Brad Turpin
DIAdem Product Support Engineer
National Instruments -
Desktop manager download and rearranging files for Pearl 8100
I have a Pearl 8100 and lost my desktop manager CD and need to load it on to my new laptop. Where can I download this? I have tried a search here at this website, but I can't seem to narrow down what I need specifically.
Also, I was wondering if it were possible to move files around, specifically, from within a folder to the desktop. For example, Brickbreaker and Messenger.
Thank you - beth
Solved!
Go to Solution.OverviewGet the most out of your BlackBerry® smartphone with BlackBerry® Desktop Software—an integrated suite of applications that manages the link between your BlackBerry smartphone and your email account, organizer and more.
BlackBerry Desktop Software FeaturesBlackBerry Desktop Software runs on your desktop PC, allowing you to:
Keep Your Desktop and Smartphone Data Organized
Synchronize your email and organizer information (calendar, contacts, memos and tasks) between your BlackBerry smartphone and your PC
Back up information from your smartphone to your PC or restore previously saved files
Easily Transfer Files, Music and Data
Transfer files between your computer and your BlackBerry smartphone’s internal memory or optional media card¹
Use Roxio® Media Manager² for easy management of your video and music files
Migrate data from a BlackBerry smartphone, Palm® Treo or Windows Mobile® based device to a new BlackBerry smartphone²
Add New Software and UpgradesLoad new applications and upgrades from your PC to your BlackBerry smartphone
Manage Your Enterprise Email
Create an auto signature to be included in the body of your outgoing email messages³
Filter the email messages you receive on your BlackBerry smartphone by key words and message fields³
Press here to download
If your issue is resolved, put a checkmark in the green box that contains the resolution.
OR
If it was just/or also really helpful - Give it a Kudos.. Go on Mate.. Help the rest of the clueless blackberry user world find their answer too..
~Gday from Down Under~ -
I've recently bought a Mac Book and am struggling to play AVI and DivX files. What seemed so easy on my old PC now seems impossible on my Mac.
I've looked at the past forums and tried a few past suggestions, but nothing works. I've tried downloading DivX for Mac with all the codecs, VLC Media Player, Perian and I've even tried coverting through DivX Doctor II.
What am I doing wrong?I don't think this fixes your problem but it at least keeps the thread going until someone with the answer posts. The one thing you didn't mention was fip4mac. I don't know it those others cover what it does or not. If you have downloaded the file you can control click on the file and select get info. When that comes us select open with. Change what ever that is to QuickTime. Sometimes that lets you view some files. I feel your pain, the change over takes a little time. Hang in there mate, it will be worth it.
-
I want to read a Matlab MAT file into labview.
I do not have Matlab. I have a series of *.mat files that are created by another program that I want to read into LabVIEW. The *.mat files should contain a very long 2 dimensional array of complex numbers, with only 2 columns. I am hoping that the *.mat format is straight forward. I need to read this into a LabVIEW array to manipulate it.
Has this been done? I've found several routines that allow you to save data from LabVIEW into a *.mat file so that Matlab can read it, but I have not seen anything that goes in my direction. Any help is appreciated.
MikeOh, yeah, that certainly makes a big difference.
You're even luckier that I was still bored, so I whipped something together.
See attached.
Couple of things:
(1) I couldn't test it for all data types so the "Parse Data" VI may need to be tweaked for some of the data types.
(2) Your file contained multiple variables and the one matrix of complex values was a 1D array so you may need to insert a "Transpose 2D Array" function where the bundle function is for your 2D array.
(3) A couple of the variables were character arrays but Matlab stores the individual characters as floating point numbers between 0 and 255 representing ASCII-encoded characters. These are the "XUnit" and "YUnit" arrays.
For your reference, the MAT file format is at http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
Oh, I think I may have left breakpoints in when I saved the VI. Sorry about that. You should remove them when you run the VI so they don't become annoying.
Message Edited by smercurio_fc on 02-09-2006 05:07 PM
Attachments:
Read Level 4 MAT File.zip 69 KB -
Hi,
I am using an lvm file after conversion from mat file. I wanted to get the fft spectrum.I keep getting this error that waveform dt<=0.
How do I overcome it?
I have attached the mat file and the vi i used.
Best regards,
Fesmi
Solved!
Go to Solution.The Forum is somewhat particular about the files which may be attached. Often creating a zip file works. Sometimes you can change the extension to .txt. If you change the extension, please indicate in your post what the orignal extension was.
It appears that the data in the file has a time column and an amplitude column. The LabVIEW waveform datatype is a cluster of an array of amplitudes (Y), sampling interval (dt), starting time (t0), and optional attributes. This is what the Power Spectrum VI requires as an input. The t0 values is not used so the defualt is fine. the dt value can be calculated from the difference of any two adjacent values in the time column. Since the first value is zero, the second value is equal to dt. Use the Build Waveform primitive from the Waveform palette. Expand it to show the dt element.
In the attached VI all rows is an indicator which contains the data from your file saved as default. XY Graph plots that data. After subtracting the mean to get rid of a DC component, the data is converted to a waveform. The power spectrum is calculated and displayed using the same VI as in your program. It also uses Extract Multiple Tone Information.vi to get the frequency and amplitude of the major peaks in the data.
Interestingly the low frequency part of the spectrum has strong harmonics of 60 Hz while the peaks near 4 kHz are space ~100 Hz apart. The broad peak near 2.1 kHz does not seem to have noticeable components at either 60 or 100 Hz.
How do you avoid the Dynamic Data Type (DDT)? Stop using Express VIs! For reasons only known to NI, Express VIs deliver their outputs via DDT. Except by opening the block diagram of the express VI, there is no way to tell what the underlying data structure on a DDT wire is.
Lynn
Attachments:
FFT of Waveforms.vi 711 KB -
Error while converting class file to exp and jca file
error while converting *.class file to *.exp and *.jca file
=====================================================================================================================
linux-y60u:/home/admin/java_card_kit-2_2_1/samples/src # converter -exportpath "/home/admin/java_card_kit-2_2_1/lib/" com/sun/javacard/samples/HelloWorld 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b 1.0 -v -applet 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b:0x01 Identity
Java Card 2.2.1 Class File Converter, Version 1.3
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
parsing /home/admin/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/HelloWorld/HelloWorld.class
parsing /home/admin/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/HelloWorld/Identity.class
error: com.sun.javacard.samples.HelloWorld.HelloWorld: unsupported class file format of version 50.0.
error: com.sun.javacard.samples.HelloWorld.Identity: unsupported class file format of version 50.0.
conversion completed with 2 errors and 0 warnings.
=====================================================================================================================i compile a file javacard use this command:
===
javac -source 1.3 -target 1.1 -g -classpath ./classes:../lib/api.jar:../lib/installer.jar src/com/sun/javacard/samples/Identity/Identity.java
===
and try to convert this class use this command
===
/home/xnuxerx/admin/java_card_kit-2_2_1/bin/converter -exportpath "/home/xnuxerx/admin/java_card_kit-2_2_1/lib/" com/sun/javacard/samples/Identity 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b 1.0 -v -applet 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b:0x01 Identity
===
result convert:
===
Java Card 2.2.1 Class File Converter, Version 1.3
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
parsing /home/xnuxerx/admin/java_card_kit-2_2_1/samples/classes/com/sun/javacard/samples/Identity/Identity.class
converting com.sun.javacard.samples.Identity.Identity
error: export file framework.exp of package javacard.framework not found.
conversion completed with 1 errors and 0 warnings.
===
why ??
please your comment for this problem.
thank 4 all.
Maybe you are looking for
-
Normally you create your menu in Photoshop and then you create a simple overlay file (using white, black, red and blue). Then you draw your buttons and select how to key and what color to use. Is there any way of using a full color-image for both the
-
Problem in Calling a report from form 6i using parameters
Hello Oracle experts, I am facing a problem while calling a report using form 6i and passing parameters, Actually the problem is I want to use the parameters passed to reports in a query group in my report. I am not able to use the parameters passed
-
2 Different Partition Map Scheme's for one external hard drive
Is it possible to have one external hard drive with 2 different Partition Map Scheme's? One of them will be used to externally boot tiger on a powerpc, and the other for use on my macbook pro?
-
Can I upload from my ipod to my computer
Can I upload from my ipod to my computer?
-
Text written into MS Word document is not translated into unicode format
Hi all, I am creating a MS word document using OLE document management interface. Then I am adding some text fields with i_oi_form->add_field. My system is a unicode system. The word document is created but characters like "á" or "ñ" become strange t