error of MathScript

Hello, I use the book "hands-on Introduction to LabVIEW for scientists and engineers" by John Essick and in Chapter 3, he says you type a code in mathscript.  However, I keep getting an error on the last line, saying: line 17, column 4: expecting 'end', found "

This is the code that I entered, copied directly from the book:

delta_t = 1/f_s
Start = 0
step = delta_t
stop =(N-1) * delta_t
t = start: not: stop

If s == 0
x = A * Sin(2*pi*f*t)
otherwise if s == 1
x = A * cos(2*pi*f*t)
otherwise if s == 2
x = linramp(A,A,N)
otherwise if s == 3
x = A * gensignal ('square', 1/f, stop, Step)
otherwise if s == 4
x = 4.0 * Sin(2*pi*100*t) + 6.0 * cos(2*pi*200*t)
end

What I am doing wrong?

Hello, jhauck

You must complete each statement 'if' with the 'end '.

Correct code would be:

If s == 0
x = A * Sin(2*pi*f*t)
on the other
If s == 1
x = A * cos(2*pi*f*t)
on the other
If s == 2
x = linramp(A,A,N)
on the other
If s == 3
x = A * gensignal ('square', 1/f, stop, Step)
on the other
If s == 4
x = 4.0 * Sin(2*pi*100*t) + 6.0 * cos(2*pi*200*t)
end
end
end
end
end

OR you can use the 'elseif ': statement

If s == 0
x = A * Sin(2*pi*f*t)
else if s == 1
x = A * cos(2*pi*f*t)
else if s == 2
x = linramp(A,A,N)
else if s is 3
x = A * gensignal ('square', 1/f, stop, Step)
else if s is 4
x = 4.0 * Sin(2*pi*100*t) + 6.0 * cos(2*pi*200*t)
end

Refer to the documentation of Matlab: http://www.mathworks.com/help/matlab/ref/if.html

Tags: NI Software

Similar Questions

  • Error in Mathscript (FOPDT transfer function)

    Hi all, I'm writing a first order system and dead time in the mathscript unfortunetaly I found that it displays an error (please see attachments), someone has an idea or an approach to write a transfer of FOPDT mathscript function?

    Thank you veery much.

    Yet one thing... This might be easier if you go 100% graphic...

    Below is a snippet and you can simply drag and drop into your LabVIEW 2011 diagram and this will copy this code in it.

  • MathScript node: an error internal mathscript: 64-bit LabVIEW 2009

    Hi people.

    I have an installation now LabVIEW 2009 9.03f, Vision and Advanced Signal Processing Toolkit, all 64-bit versions on a new computer, so that I can convert a code from 32 to 64-bit.

    I tell myself that I will address the errors one by one and this is the first.  I have a VI with mathscript node and the VI, who instructed and ran very well in the 32-bit environment, is now broken and giving the error "mathscript node: a mathscript internal error."  My main concern - is mathscript unsupported in LabVIEW 64-bit right now?

    I enclose the VI.  Any ideas are appreciated.  I need to get this working.

    In addition, NEITHER is there a special forum of 64-bit we should publish in the future, or create to post on?

    Sincerely,

    Don

    2009 help

    LabVIEW MathScript is a language based on text that you can use to write scripts and functions. You can process the scripts using LabVIEW MathScript in the Window of LabVIEW MathScript or a MathScript node. When you create a LabVIEW MathScript, you use data types supported.

    The MathScript syntax is intuitive and logical syntax essentially based on the standard mathematical and computer programming terms, mandate of widespread and common use truncation or descriptive abbreviations and concatenations of standardized terms. The Window of LabVIEW MathScript and MathScript nodes are able to process files that you create using the MathScript current syntax and, for backward compatibility, files that you created using legacy MathScript syntaxes. The Window of LabVIEW MathScript and nodes MathScript can also process some of your files using other textual syntaxes, such as files that you created by using the MATLAB® software. Because the MathScript RT Module engine is used to treat the scripts in the Window of LabVIEW MathScript and MathScript node, and the MathScript RT Module engine can't stand any of the syntaxes, not all existing text scripts are supported.

    (64-bit LabVIEW) LabVIEW MathScript is not supported in LabVIEW (64-bit).

  • How to share a variable between the Mathscript Windows and a Mathscript node

    Hello

    I'm trying to share (just) a variable between the Mathscript Windows and a Mathscript node. I don't know why, but the use of the "global" Matlab function makes the mathscript node output formats change.

    I'm looking for a "Mathscript RT V9.0.1 module" as it may seem, there is. French technical support have some difficulty to find...

    Hi patrick33,.

    The code that you have attached should not report an error, so it seems that something has gone wrong with your installation of MathScript. My best guess is that it is the problem that is described in this knowledge base article. Your signature says that you use f3 patch, which is a good start. But the KB lists some other steps to take when you see errors about MathScript, impossible to compile. Can you try the procedure described in the article and let us know if that fixes the problem?

    Thank you

    jattas

    LabVIEW MathScript R & D

  • Module MathScript RT expired license

    Why the Mathscript RT Module is not supported by Labview 2010. It gives the error "Module MathScript RT expired license"

    Please suggest

    You did a search for "Mathscript" do you have? Asked the exact same question two days ago.

  • mathscript node Mac could not compile

    I just installed LabView 2009 SP1 on Mac OS X (Snow Leopard), as well as MathScript, who can't do much beyond a simple assignment.

    A simple if-else structure will work if it performs only scalar assignments, drunk, trying to create a simple 1 d of table within a node structure MathScript (x = 1:1:10) causes VI to break with the error ' MathScript node: VI failed to meet. "

    Similarly, try the following commands in a MathScript window all give "error at line 0: an internal error occurred during the processing of this MathScript.» Contact National Instruments with the MathScript you used. »

    t = 1:1:5

    t = linspace (1,5,1)

    help linspace

    It's not yet the command help. The only thing that works is something like x = 5 or x = sin (2.2 * pi).

    I am aware of these two articles, or which is applicable for Mac or for 2009 SP1:

    59AH3P4A Knowledge Base: Causes of failure Compiler Error with MathScript node

    553C13WI knowledge base: Detection screw instantiation corrupt and MathScript node failed to meet Er...

    The second section offers a few folders to delete, which I've tried. The other does not exist on install Mac. Needless to say that the utility to find corrupted instantiations is not useful here.

    Thanks in advance for your suggestions.

    Tom

    Inches,

    Is that you improved in 2009 SP1 MathScript RT? The 2009 version of MathScript won't work with LabVIEW 2009 SP1.

    Thank you

    Scott K

  • An internal error occurred during the processing of this Mathscript

    I tried to run a ".m" file it starts with a number of % "commented" statements to help the program implemented. "  I get this error as above as "internal error in row 0, then the error message. Please notify it is a problem using % or else where in the program?

    Chuck

    Hello Chuck,

    This error indicates there is something in your script that LabVIEW MathScript did not understand.  As such, it depends on the script that you typed.  Is it possible to attach your script?  If this isn't the case, you can try a binary search with your script.  Remove half of your script.  If the problem persists, the culprit is in the half top.  Remove half of the upper part of the half and reaffirm.  If this isn't the case, it is at the bottom half.  Add in half of the text you removed and try again.  After you have identified where the problem occurs, you can try to simply the script by removing other lines that are not necessary to run the problem line.  If then you can put what you have, I can investigate on what is wrong.

    It is possible that comes to mind if you perform a replacement of indexation of the following form:
    [(m, n) vs s] =
    In other words, one of the values of multiple return putting inside another matrix.  A solution for this is to do the following:
    [s] = so.
    vs (m, n) = a;

    Grant M.
    Staff software engineer | LabVIEW Math & Signal Processing | National Instruments

  • MathScript syntax error

    Can someone let me know what the syntax error in the present

    If ((A > = 1,70) & (a)<>
    A = 1
    If ((A > = 1.34) & (a)<>
    A = 1
    If ((A > = 0,925) & (a)<>
    B = 1
    If ((A > = 1.305) & (a)<>
    B = 1
    If ((A > = 1,935) & (a)<>
    C = 1
    If ((A > = 1,72) & (a)<>
    D = 1
    If ((A > = 1,70) & (a)<>
    E = 1
    If ((A > = 1,65) & (a)<>
    F = 1
    If ((A > = 1,29) & (a)<>
    G = 1
    If ((A > = 1.0) & (a)<>
    H = 1
    on the other
    I have = 1
    end

    Thank you chris

    I suppose you want all these s if (except the first) to be an elseif.  If this isn't the case, then you want to terminate after each individual case.

    In addition, it is not a bad idea to start one; at the end of each statement.  (Not the lines containing if, elseif or end)

    In addition, you probably want to use & instead of &.  I don't know if mathscript makes a distinction between the two, but I know some languages.  The help file for use mathscript &, then I'd go with that.  Someone at - it care to confirm if there is a difference?

  • Find Permutations using perms in MathScript throws memory is full error

    I use the perms Mathscript function to find the possible permutations of the numbers to a number in a table.  According to the Help function permanent , he agrees to 15 items or less.  I can feed this function up to 9 items, but when I try 10 I get the error: LabVIEW: memory is full.  I increased virtual memory by the suggestion in why I am getting "memory is full" error KB.

    The error occurs when Windows Task Manager reached 628 M no matter what I change my virtual memory.  I have 2 GB of RAM in my computer.  Any suggestions?

    Thank you

    What is expected. With N = 10, the final matrix will be 10! x 10, or approximately 36Million DBL elements. Each contains 8 bytes, which bears the imprint to ~ 290 MB for a single copy of the matrix of results expected.

    Looking at the memory usage of the VI for N = 9, is already 100 MB, so it seems there are about 4 copies of the final table in memory. No wonder that N = 10 is impossible.

    I recommend to the instruments in plain LabVIEW (son and loops) with a data type of U8, you will probably be able to go higher than 9.

    Remember that 15 is unrealistic, because the dimensions of the matrix are I32, but the size of the array will be N!. This means that you don't have enough lines for example N > 12 anyway.

    You have a good reason that you need such huge tables?

  • MathScript error 90011

    Hello

    I work with "hands-on Introduction to LabVIEW for scientists and engineers" by John Essick.  I'm stuck on the issue of 'do it yourself' at the end of Chapter 3.  Everytime I go to run the program I get this message:

    90011 error occurred to the error in function * on line 7: the sizes of the input matrices are not compatible.  Check that the matrices have the same size or one is a scalar. Possible reasons: LabVIEW: sizes of the input matrices are not compatible.  Check that the matrices have the same size or one is a scalar.

    This is the code that I entered:

    delta_t = 1/f_s
    Start = 0
    step = delta_t
    stop =(N-1) * delta_t
    t = start: not: stop

    x = A * (1 + Sin(2*pi*MF*t)) * sin(2*pi*SF*t)

    And I join the VI (during the execution, the book says to take N = 500, f_s = 10000, sf = 500, mf = 50 and A = 1)

    Any ideas?

    So it took me about an hour, but the right after I posted the here, I thought about it.  I need to replace ' * 'by'. '. ' * ' for the multiplication of cross-checking.

  • '' If '' dosnt works at the mathscript node

    Hello

    I have a strange problem in mathscript node, can u help me?

    I just wrote a simple conditional style in the mathscript node, but it dosent work and have attached the error! my software has problem?

    Best Regarsd

    Behzad

    The problem is that your "out" is not defined, as executed in your script. Maybe it's what you want instead

    out = - 1; % define value as default for the

    If in == 7

    out = 6;

    end

    Kevin C.

  • In 2012 LabVIEW MathScript RT module does not work

    Hi all

    I recently installed LabVIEW 2012 in my PC with Windows 7. However, Mathscript does not at all. It says "an internal error has occurred in the MathScript RT Module.  Restart LabVIEW and try again.  If the error persists, reinstall the MathScript RT Module. "I did it, but still does not work. It is said further than Mathscript is missing or not installed", but I have installed. What the problem would be, please?

    Have you been able to verify the installation and activation in the License Manager OR? It should say enabled for this computer and have a green square like this:

  • "print" command in Mathscript recording is not the plots in BMP format!

    Hi guys,.

    I am creating a vi that automatically generates a pdf for my project report. I found a way to record the report directly in pdf format (in other words, I have 'print' my report to a (PDFCreator) Virtual PDF printer that saves the file in a specific folder with the date/time under his name.) "So, this was the first step to make the automatic procedure).

    I'm stuck in the next step, which is adding to the report no graphics bad appearance of labview, but the plots of the victims of the Mathscript.

    Yes, after you have added as input 'a' my data to the mathscript node, I use the following commands:

    Figure

    Plot (a)

    print the image

    Now, what is this sequence is to do a beautiful land of my data and then save it as "image.eps" in the default folder.

    However, the eps format is not at all useful to me because I can't import the plot with the 'Add Image to Report.vi '. This vi supports the formats BMP, GIF, WMF, EMF and JPG only.

    So, I want to save as BMP mathscript plot. It's supposed to be possible, but I have not been able to find a way. Using the command 'Print' for Labview Mathscript 2011 reads as follows:

    http://zone.NI.com/reference/en-XX/help/373123B-01/lvtextmath/msfunc_print/

    Syntax


    print

    Print (a)

    Print (file)

    printing (, file)

    Description


    Print the trace window, or save it in a file in BMP or EPS format. If the trace to save window is a plot of the image or a 3D terrain, the file must be in BMP format. Other types of plots, formats BMP and EPS are supported.

    There is no way for me to choose what format I want, and it automatically selects the eps. If I use the command

    print image.bmp

    It gives me an error. So adding the endpoint .bmp is not the way to go.

    Overall, it is essential for me to export the plot in BMP format (in order to import it into the generation of report), but I can't find a way, althouth it is supposed to work.

    Any ideas?

    Thank you

    PS. I run Labview 2011 SP1

    Hello

    You must use the following command

    Print ('test.bmp')

    Instead of

    print test.bmp

  • updated 2009 LabVIEW Mathscript

    Hello

    I developed an application in LabVIEW 8.6 who
    contains a large MathScript node. It's time to upgrade to LabVIEW 2009
    and I am facing problems in that. I have the Mathscript RT Module
    installed and enabled on my computer.

    I want to emphasize that
    the application works perfectly at 8.6. After the first performance in
    version 2009, I got 2 errors:

    -90031: "unknown output."
    variable. The variable is a string. He showed up in a red dot
    (see photo). I've never seen this before red dot...

    another
    error in another node:-20104: input parameter have at least a NaN
    element. What is an element of NaN? This error occurs in a line that looks like
    as A = median (B) where B is a vector line.

    also in this second
    node, I have a lot of output shown in the red dots, the string variables
    outputs and some double precision as well.

    What
    are the requirements to upgrade to LabVIEW 2009, insofar the MathScript
    is concerned? There are issues to be addressed? major changes, I should
    Be aware of?

    Thank you very much

    Sam

    Hi Sam,

    You can define variables by their wiring as inputs or by setting them in the script of the node.

    If your solution is still available in 2009. In fact, this looks like the right solution to get the behavior you're looking. I think that the reason that it does not work is that there is still some output variables that need to have your solution that are applied to them. These output variables are currently not be wired in the shift registers MathScript node and are only defined in the case of statements which are false, when your code is running. So, if wire you these variables in the MathScript node, the errors should go away and you will not see the default values.

    Initialization of variables in the upper part of the MathScript is another way to get rid of the error. However, it seems that this is not the best solution in your case because you want the variables to receive the same value they had at a previous time, that run MathScript node. The best way to do is with registered SHIFT wired as inputs to the node.

    The reason for this change in behavior between 8.6 and 2009 is indeed to help users find bugs or logical errors with their code. The new behavior makes it less likely that downstream from the MathScript node code tries to use an output that has an invalid value (by default).

    I hope that this explanation makes things a little clearer.

    Thank you

    jattas

  • MathScript failed to meet

    Hello!

    I am using a node Mathscript in BT 8.5.1, but without success. I get the

    error 'Failure of VI to compile' and the Mathscript is 'marked as main error ".  I have

    used Mathscripts before, but never had these problems. I use Windows XP SP3.

    Everything works fine when I try the example of Labview Mathscript.

    You have a solution for this problem?

    Thanks in advance!

    / Mattias

    Hello Mattias,.

    This looks like a subtle problem.  You have a control located at "affix 2009-04 - 17\Data.ctl.»  Unfortunately, MathScript also uses a control called 'data.ctl.'  LabVIEW will not allow two separate controls with the same name be in memory at the same time.  It seems that your order is already in memory when MathScript starts to load, so it binds to your control instead.  This causes internal errors and signals that the VI cannot be compiled.  The only solution now is to rename your control to something other than "data.ctl."  We work on solving cela and hope to be in a future release.

    Grant M.
    Staff software engineer | LabVIEW Math & Signal Processing | National Instruments

Maybe you are looking for