LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get a better feedback from matlab script

Hi everyone,

I'm using matlab script from LabView. It seems to work, my server receives correct data but I would like to get some useful outputs. For instance, for debugging purpose, I'd like to be able to get messages sending by fprintf. And more generally, I could see if my script is crashed or running.

Any idea?
0 Kudos
Message 1 of 3
(2,907 Views)
You are able to do a fprintf through a script node. I just used the example from the matlab help for fprintf to verify this. The one thing that I needed to change was the path to the file. I am not sure what the working directory is when running through a script node so I used a full file path. Here is the code I ran in the script node:

x = 0:.1:1; y = [x; exp(x)];
fid = fopen('c:\exp.txt','w');
fprintf(fid,'%6.2f %12.8f\n',y);
fclose(fid);

I am not sure of a way to check and see if the script is crashing or running through the script node, but a possibility would be to break the script down into smaller scripts and checking return values from these smaller subsets. Just an idea.
0 Kudos
Message 2 of 3
(2,907 Views)
I "improved" my program by using as often as possible LabView to let Matlab just do the computation (LV is opening image, reading data sheet and send it as input for Matlab).

And, as you've said, I split my big script into several one which is really better.

Though, the main computation lasts 2min and it s a pity to wait such a long time without being sure of what's happening.

One "solution" is to use a 'STEP' variable which is incremented along the computation under Matlab and use it as an output/indicator for LabView. So, if step didn't reach its max, it means that you can go back to debugging.

An idea for LabView 8.0: create a kind of screen able to receive the standard output of Matlab 😉
0 Kudos
Message 3 of 3
(2,907 Views)