LabVIEW MathScript RT Module

キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Plot a labview waveformfrom mathscript

I have this MathScript code. It works fine in MATLAB and Math Script...
 
t = (0:0.0000001:0.01);
f1 = 0.0011312*cos(2*pi*49400*t);
f2 = 0.003936*cos(2*pi*100*t);
H = (f1.*f2);
x = ((2.93464*10^-10)*H);
ms = 1000;
M = ms*(coth(x) - (1./x));
 
I want to plot a waveform of M vs t in Labview. How do i go about doing this?
0 件の賞賛
メッセージ1/5
8,786件の閲覧回数
Kris,

You have a few options for graphing data in LabVIEW MathScript:

  1. Create a Waveform

    The waveform datatype in LabVIEW is a cluster of three elements.  One is the array of values (in your case M), the next is the dt value or the time between samples (in your case 0.0000001) and finally the t0 value or start time (in your case 0.0).  You can use the "Build Waveform" VI to put the pieces together and wire it to a Waveform Graph indicator.  See the screenshot below for how to implement this.

  2. Use the XY Graph

    You could use the XY Graph by bundling together the t array and the M array.  Again I've demonstrated how to do this in the screenshot below.

  3. Use the plot() command

    If you don't need the plot on your front panel and just want to see the results in a popup window you could simply use the plot(t, M) command.
すべてをダウンロード
0 件の賞賛
メッセージ2/5
8,783件の閲覧回数
Oops -- I didn't edit my own post in time.

Here's the sample code I used:



And here are the resultant plots:





Result of plot(t,M):


Hopefully this answers your question.  If not let me know and I'll try to help you out.

Regards,

Simon H
Applications Engineer
National Instruments
http://www.ni.com/support/


Message Edited by Simon H on 12-10-2007 05:32 PM
0 件の賞賛
メッセージ3/5
8,779件の閲覧回数
Thanks for the Help. But i am still not able to do it. I think because in your representation you are using 'M' as a sine wave whereas in mine i am using M as a matrix.
In my case i am getting an error where in my wire from M does not connect to the Y in the build waveform. Also which one am i supposed to use for build waveform...analog or digital...i've used both, it doesn't work.
 
Thank you,
K
0 件の賞賛
メッセージ4/5
8,768件の閲覧回数
Hello Kris,

In both your example and Simon's example, M is a one-dimensional vector.  When you create output variables on the MathScript node, make sure to right-click the output variable and select "Choose Data Type."  In this case, select the 1D array of double.  This should fix the broken wire you are seeing.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 件の賞賛
メッセージ5/5
8,754件の閲覧回数