cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

how to load a variable using MATLAB Script?

I need to load a selected variable from .mat file, using MATLAB script , and analyse it.

 

the attched shows my vi, there are two inputs nodes 'file' contains the .mat file path, and 'varn' contains varibale name in that .mat file which can be selected by user. Using " load(file)" the whole .mat file is loaded in the workspace and become avaiable at output node, however I am not able to pass a selected variable name through string "varn" input, MATLAB script does not recognize the variable.

any idea to reslove it is realy appreciated.

 

0 kudos
Mensaje 1 de 5
5.962 Vistas
Instead of a String Data Type, I used Path Data Type and was able to get it working in MATLAB Script node
Andy Chang
National Instruments
Mensaje 2 de 5
5.941 Vistas

Andy,

 

I used Path data type to pass the variable's name , by converting string to path, however I recived error message 1050!, do I need to convert back Path to string?(please see the attched)

 Thanks,

 

 

0 kudos
Mensaje 3 de 5
5.900 Vistas
Download the VI and .MAT file. Run the VI, and it'll plot the data inside of the .MAT file.
Andy Chang
National Instruments
0 kudos
Mensaje 4 de 5
5.872 Vistas

Thanks for the reply Andy,

 

My code is able to load the *.mat file but not able to pass a selected variable's name to the Matlab Script , here is an example:

 

assume in *.mat file , testfile.mat that you sent, there are V-char1, V-char2,V-char3,....., and V-char100, now using a Enum in front panel the user should be able to select one variable  name at a time , for example V-char50, and plot it.

in my code "varn" input node is supposed  to do this job.

after loading the *.mat file " load(file)" when I typed the variable name directly " plot(V-char50) it works , but if I select " V-char50" from front panel and pass it through "varn" input does not recognize the varaible's name .

 

0 kudos
Mensaje 5 de 5
5.856 Vistas