LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compile wavread on MatLab Script?

I'm having trouble compiling the MatLab function wavread on my MatLAB script node in my LabVIEW file. I even tried it with a simple

Y = wavread('blah.wav') and it would not compile. This works in the MatLAB program. Please help! Thank you.
0 Kudos
Message 1 of 6
(5,401 Views)
When you say it will not compile, do you mean you've got a broken arrow or you get an error? If broken arrow, what does the error list say the problem is? If you're getting an error out of the Matlab Script structure, what is it?

I've tried this on LV 6.1 and Matlab 6.5 and it works fine for me. Post your code & we'll try to help.

Tim
0 Kudos
Message 2 of 6
(5,401 Views)
Also, check out this link - don't know if it addresses your problem.

http://digital.ni.com/public.nsf/websearch/4475BC3CEB062C9586256D750058F14B?OpenDocument
0 Kudos
Message 3 of 6
(5,401 Views)
Hi Shan,

I get an error when compiling my code. The error reads:

Error occurred while executing script. Error message from server: ??? Error using ==> wavread. Cannot open file.

I attached my VERY simple code to read in a user-inputted .wav file, and the sample wav file. The output is the sample spectrum in a nx1 matrix. Thanks!
Download All
0 Kudos
Message 4 of 6
(5,401 Views)
Janet,
Remove the quotes around blah.
Just put in your MATLAB Script Node
f=wavread(blah)
With the quotes, MATLAB was trying to read the string 'blah', and not the blah input, which is 'annano.wav'

Zvezdana S.
National Instruments
Message 5 of 6
(5,401 Views)
I've looked at your code. OK, so the error occurs at the matlab script node (not compiling / running). If it was a "compile" error, you would get the broken arrow.

Two things to solve this problem. (1) Get rid of the quotes around 'blah'. If you give it a string, the Matlab function tries to read a file named blah. (2) Put the full path (using Path to String.vi) into the input variable 'blah', instead of just the name. Unless the file you specify in your Matlab path, it Matlab won't find it. See the attached example.

Alternatively, you could read the wave file with LV. The only difference is in the scaling. Matlab scales the wave file to +/-1, while LV will report it in bits, depending on what format the data is in.

Hope this solv
es your problem.

Tim
0 Kudos
Message 6 of 6
(5,401 Views)