LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a .m file from inside a mathscript node

Chris,

I am unable to duplicate your problem with the code you posted.  In fact, it compiles and runs without a problem here.  In order to call it, I typed
A = 1:10;
[st00 en00 Z] = noisy_region_remove_puls(0, A, 0, 0);

What issues did you find with parentheses and & signs?  I'm not sure if you changed lines of code in this file, but the if statement probably isn't parsing as you intended:
if Z(i) == 0 and (Z(i) - Z(i-1) < 0)
      st00(k1)=i;
      k1=k1+1;
elseif Z(i-1) == 0 and (Z(i) - Z(i-1) > 0)
      en00(k2) =i-1;
      k2=k2+1;
end

parses as

if Z(i) == 0
   and(Z(i) - Z(i-1) < 0)
   st00(k1)=i;
   k1=k1+1;
elseif Z(i-1) == 0
   and(Z(i) - Z(i-1) > 0)
   en00(k2) =i-1;
   k2=k2+1;
end

Most likely what you want is
if (Z(i) == 0 && (Z(i) - Z(i-1) < 0))
elseif (Z(i-1) == 0 && (Z(i) - Z(i-1) > 0))

The code still compiles correctly with those changes for me.  What version of LabVIEW are you using so I can make sure to try to compile this code in the same one: 8.0 or 8.0.1?  Also, if you load this file into the script editor in the MathScript window and click Save & Compile, what is displayed in the Output Window?

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 11 of 14
(5,304 Views)
 
0 Kudos
Message 12 of 14
(5,284 Views)
Grant,
As to the version, I upgraded to 8.01 today, and it didnt make any difference.  I also tried again with the original file just to make sure the if statements will not be an issue, attached is a capture of the mathscript window after a save and compile.  I will copy the original code below for your convienience.
 
the issue I had with the parenthesis is whe i had for (i=1:1) I would get an expecting IDENTIFIER, found '('  error.
 
Thank you
Chris
0 Kudos
Message 13 of 14
(5,281 Views)
Chris,

I have tried modifying the previous script you posted to look like the one in the image.  Using the "Save & Compile" button, I still have no problem getting the script to compile.  However, it occurred to me that I was saving the file with the same name as the function; namely, noisy_region_remove_puls.m.  If I use a different name, then I get the error that you see.  What filename are you using to save the file?  If it is different, try saving the file with the same name as the function.

If this is not the issue, I'll need more information as it may be a more subtle problem.  But before we venture in that direction, let me know about the file names.  As for the parenthesis error you encountered, we have seen that issue before and plan to fix it for a future release.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 14 of 14
(5,270 Views)