LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab scripts that function properly when run in matlab generating errors in labview

Highlighted
Hi, I'm running LabView 7.1 and trying to use some matlab scripts in my lab view script.

The code runs fine in matlab, but when I run it in lab view I get errors as follows:

"LabVIEW:  Error occurred while executing script. Error message from server: ??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> extract_inl_NI at 46
      .
 in array_test.vi"


There is no division in line 46 (in fact it's a blank line).  Are there syntax changes that I may not know?  Or perhaps a way to compile my code to ensure it runs correctly?
0 Kudos
Message 1 of 5
(739 Views)
Hello,
 
A couple of things will be helpful, and may even lead you to find the problem.
 
1. Reduce your script code to something as small as possible that causes the error - this will give a better idea for what's causing the problem.
2. Post the VI and the code here so we can take a look at it.
 
The line indicated in errors in various environments is often off by one for where you actually need to fix the problem.  Try looking at the line before and after to see if something there may be a problem.  As you reduce your code, you can also see if the error line changes, and use that difference to further decipher where the problem is.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 5
(730 Views)
Thanks for your response.  I've found more success by avoiding calls to external functions (I just copied the code into the Matlab script box in the block diagram instead), but am still seeing inconsistent behavior to running in Matlab alone.

My code does have a few for loops, a couple of them nested, and various calls to other matlab functions.  Are you aware of any problems/issues this may cause?  I am not seeing any errors now.  The setup is as follows.


x = random   ->  f(x)  -> output to plot

f(x) is my code, and the entire sequence is placed in a while loop in the labview block diagram.  I have probed x and see that it changes continuously, however the output on the plot remains the same. 

I can post more code specific information if you feel it would be helpful, but what I'm really looking for is if there is something fundamental about matlab for loops or using matlab function calls while in a labview while loop.

Thanks.

-A
0 Kudos
Message 3 of 5
(717 Views)
Specifcally, is it possible to use the plot function?  I'm getting very mixed results on this.  Sometimes the matlab command window generates a plot and other times not.  I suspect some variables in my matlab script are holding their value from previous iterations in the labview for loop.  It has been helpful to explicitly reset them.
0 Kudos
Message 4 of 5
(719 Views)
Hello,
 
Can you post your code (VI) here, or better yet a simplified version of it which still causes a problem.  If you can also post a simple version which functions as you expect, that would be nice, but it sounds like the plotting problem is intermittent.  This should work, per the following document, but perhaps there's an issue:

http://digital.ni.com/public.nsf/websearch/57FE03DA9C357E9486256A0D00739CA6?OpenDocument

Hopefully after seeing the code I will have more ideas about what may be going wrong.  As a final thought, are there any parameters to the plot function which can be passed to make it show the plot or make it the active window... could this be a very strange UI feature?  I guess it will make more sense when I see the VI(s).

I look forward to your repost!

Best Regards,

JLS

Best,
JLS
Sixclear
0 Kudos
Message 5 of 5
(704 Views)