LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview/ matlab interface

I have a LabVIEW program which has a subVI which calls a MatLab program to read some files and perform some calculations (screenshot attached). I want to make some changes in the program such that when a button is switched on in LabVIEW the MatLab code reads file (a) and when it is off, it reads file (b). How do I such an interface between LabVIEW and MatLab? 

 

MATLAB call.jpg

0 Kudos
Message 1 of 9
(3,362 Views)
Can you pass the filename into the math script node as a parameter?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 9
(3,345 Views)

Why not make the path an input to the subVI and use a case structure in your main VI to determine the path prior to calling the subVI?

0 Kudos
Message 3 of 9
(3,337 Views)

%electricity price
Eprice_72per = xlsread('price.csv','D2:D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('price.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('price.csv','B2:B73'); 

 

This is the original part of the program. But I want something like this:

 

%electricity price

if (Boolean_fromLabVIEW = true)

Eprice_72per = xlsread('sameprice.csv','D2:D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('sameprice.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('sameprice.csv','B2:B73'); 

else

Eprice_72per = xlsread('price.csv','D2:D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('price.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('price.csv','B2:B73'); 

 

I tried adding nodes to the MathScript on the LabVIEW program, but it shows the following error:

 

error.jpg

 

 

So what you're saying is wire the boolean to a case structure or select function and pass the path of the files through the node depending on boolean value? 

0 Kudos
Message 4 of 9
(3,327 Views)

Sorry about the smileys, code:

 

Eprice_72per = xlsread('price.csv','D2 : D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('price.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('price.csv','B2:B73'); 

 

This is the original part of the program. But I want something like this:

 

%electricity price

if (Boolean_fromLabVIEW = true)

Eprice_72per = xlsread('sameprice.csv','D2 : D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('sameprice.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('sameprice.csv','B2:B73'); 

else

Eprice_72per = xlsread('price.csv','D2 : D73')/1000; 
[num,EpricePeriod1,raw] = xlsread('price.csv','A2:A73'); 
[num,EpricePeriod2,raw] = xlsread('price.csv','B2:B73'); 

0 Kudos
Message 5 of 9
(3,325 Views)

Did the code work before you made changes?  If so, change all references to a file to match the file you want.

 

But, what are you really gaining from this?  What is the script doing that you cannot do easily without involving the mathscript node?

0 Kudos
Message 6 of 9
(3,303 Views)

This is just part of the code, the actual code is 1600 lines long. 😛 (written by someone else)

 

The line:

if (Boolean_fromLabVIEW = true)

 

was just to give you a clearer idea of what i want to achieve. the problem is how do i make matlab read the status of this boolean button and act accordingly!

0 Kudos
Message 7 of 9
(3,295 Views)

If that's your issue, you're asking how to debug matlab code.  You'd want to do that on the mathworks forums.

 

People here help with LabVIEW code. 

0 Kudos
Message 8 of 9
(3,284 Views)

I just want to know how to pass the boolean from LabVIEW to MatLab, the code is not an issue.

0 Kudos
Message 9 of 9
(3,280 Views)