LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

MathScript Observations

I just started playing with the Interactive MathScript environment today.  I read through the tutorials on the web site, which were helpful in getting started.  My next step was to run one of our fairly complex matlab m-files.  There are three files, a .mat data file, the "MyFunction" function .m file, and a .m script file that just loads the data file and runs the function with the loaded data.  Here are my comments:
  • I had to modify the load statement from "load Dataset1v6.mat" to be more specific "load 'c:\temp\Dataset1v6.mat'", which was a little annoying, but not that painful.
  • It drives me crazy that every line of the script file gets displayed in the Output Window.  When I run a script in Matlab, I don't expect to see the comments, any statement with a semi-colon, and any statement like a sprintf or disp - just the output.  The Output Window becomes very confusing to follow.
  • I have yet to get the script file to run my function.  Everytime it gets to the line to run it, I get "Unknown symbol on line 11: MyFunction".  I tried using "cd" to get to the folder where the files are - didn't work.  I tried adding the folder to the MathScript path - didn't work.  I just can't figure out what I'm missing.
  • There doesn't seem to be any way of re-sizing the Command Window or the Output Window, which is frustrating.
  • It would be nice when spawning a new script window if there was an option to dock as another tab or a separate window.
I'm dying to get this to work, so I can show the Matlab folks at my company what cool stuff is available in LabVIEW!

Thanks
0 Kudos
Message 1 of 10
(11,077 Views)

Derek,

We actually have a dedicated MathScript forum:

http://forums.ni.com/ni/board?board.id=MathScript

Check it out! 🙂

(Also the upgrade notes to the just released Labview 8.0.1 upgrade mentions a few mathscript related bug fixes)

0 Kudos
Message 2 of 10
(11,069 Views)
According to the NI Forums navigation breadcrumbs, I *am* in the LabVIEW MathScript forum.  When I click on your link, I see my post there.  Am I missing something?

Thanks
0 Kudos
Message 3 of 10
(11,066 Views)
Either I was very confused or a moderator moved the thread. 😉
 
(Both things happen once in a while :))
0 Kudos
Message 4 of 10
(11,065 Views)
Can anyone explain why I can't load my m-file function from another m-file?  This is driving me crazy!

Thanks
0 Kudos
Message 5 of 10
(11,046 Views)
Derek,

Thank you for your comments.  Let me address them in the order that you presented them:
  • You shouldn't need to specify the full path to your data file in the load command.  MathScript will search the current working directory for the filename you specify.  However, it is true that you need to enclose the filename in single quotes.
  • If you have loaded your script in the Script Editor and then clicked the Run button, all of the text will be copied to the output window.  If you wish to avoid this output, simply call the script by typing its filename in the Command Window.
  • If your script is unable to call your function, check the capitalization of the filename on disk versus the capitalization of the line that calls the function (e.g. If your filename is myfunction.m, make sure your call reads "myfunction(x)" and not "MyFunction(x).")  In LabVIEW 8.0 MathScript, user-defined function calls are case sensitive.  This will be changed in LabVIEW 8.1 MathScript.
  • While you cannot change the proportions of each window element, the MathScript Window itself can be enlarged.  This will enlarge the area of the Output Window.  The Command Window is meant to be used for executing small commands.  For larger sets of commands, we recommend using the Script Editor and running the commands directly or saving them into a script file to run by typing the filename.  We will consider adding a way to resize the individual elements in a future release.
  • These are also a couple of good suggestions that we will consider in the future.
Try these suggestions and see if your files now run.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 6 of 10
(11,034 Views)
Hi Grant,

Thanks for the reply.  I'm still having trouble getting my m-files to run.  Here's exactly what I'm doing:

I have three Matlab files that I've copied to "C:\Documents and Settings\<mylogon>\My Documents\LabVIEW Data\".  These files are:
  • Dataset1v6.mat - a Matlab v6 data file
  • runsd.m -  a simple file that loads the previous data file and calls the next file, which is a function.  Here are the contents:
    disp( 'Loading v6 data...')
    load 'Dataset1v6.mat'
    disp( 'Running signal detection algorithm - please wait...')
    sigdetectv6(RD, Rall, adj_hits, t) ;
  • sigdetectv6.m - proprietary signal detection function
Here's what I try to do to run these files:
  • Start LV8 and select MathScript Window from the Tools menu.  I don't open any VI's, etc.
  • Clear all history, variables, and scripts.
  • Load runsd.m in the Script tab.
  • Select Run from the Script tab.  Here is the output:

    disp( 'Loading v6 data...')
    load 'Dataset1v6.mat'

    disp( 'Running signal detection algorithm - please wait...')
    sigdetectv6(RD, Rall, adj_hits, t) ;

    Loading v6 data...

    load from: C:\Documents and Settings\dprice\My Documents\LabVIEW Data\Dataset1v6.mat

    Running signal detection algorithm - please wait...

    Unknown symbol on line 12: sigdetectv6
It just doesn't seem to like sigdetectv6.m.  I know I'm probably missing something very obvious - what is it?!

Thanks,
Derek
0 Kudos
Message 7 of 10
(11,028 Views)
Derek,

After looking at the code you posted, it all seems correct and indeed runs on my system if I create sample Dataset1v6 and sigdetectv6.m files.  This leads me to believe that there is some unsupported syntax in that function.  MathScript tries to compile the files, if needed, when they are called.  If there is an error in the function and it is unable to compile, you will see the unknown symbol error.  There are a couple of options to try to determine if this is the problem.

1) Load sigdetectv6.m into the Script Editor.  Click the Save & Compile button.  This will save the file and attempt to compile it so that LabVIEW can run it.  Any compiler errors will be reported in the Output Window.  Currently, this is the only mechanism where function compiler errors are reported.

2) Load sigdetectv6.m into the Script Editor.  Comment out the line declaring the function.  Load your data file and make sure that the actual parameter names passed to the function match the formal parameter names expected by the function.  If not, rename your variables to what the function expects.  Then click the Run button.  Since the body of the function is running like a regular script, any errors will be reported.

Either one of these options should report any errors in the file.  If this is the case, you may be able to make a simple modification to work around the problem.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 8 of 10
(11,017 Views)
That was the problem. One of the data fields loaded from the .mat file is a structure that contains a cell, doubles, double arrays, etc.  I don't think that was supported with MathScript.

Thanks,
Derek
0 Kudos
Message 9 of 10
(11,014 Views)
Derek,

I'm glad you were able to locate the problem.  But you are right: cell arrays and structures are not supported in MathScript at this time.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 10 of 10
(11,010 Views)