From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-07-2014 08:50 PM
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?
10-07-2014 09:08 PM
10-07-2014 09:14 PM
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?
10-07-2014 09:48 PM
%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:
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?
10-07-2014 09:49 PM
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');
10-07-2014 11:34 PM
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?
10-08-2014 12:14 AM
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!
10-08-2014 12:42 AM
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.
10-08-2014 01:22 AM
I just want to know how to pass the boolean from LabVIEW to MatLab, the code is not an issue.