Matrix of MathScript

Hello

I have a simple question. See the file jpg or vi. The size (y) is m = 1 and n = 101 but 'y' output is a scalar value (no matrix and not in table). How to display the 'y' on the chart outside the MathScript service and why the output of 'y' is not a matrix?

Best regards

Maciej

You must configure the output of the tunnels for the type you want.

Right-click on the exit tunnels and select "choose the type of data... matrix... real matrix" or "select the data type of...". Table 2D... DBL 2D", as the case may be.

Tags: NI Products

Similar Questions

  • Improved speed for the LabVIEW MathScript calculation

    I use a MathScript node to perform calculations on a sbRIO FPGA module and the speed of these calculations is critical.  What are some ways to improve the speed of calculations and y at - it a faster way to make calculations of MathScript matrix?  If I belong the MathScript in a Subvi it will improve the speed of calculations?

    Thanks for any ideas

    Please look at the VI attached. She is your original code ".m", my changes to your ".m" and G code equivalent to the updated code ".m". First, let me describe the numbers that I've seen on a cRIO 9012 for each of the three approaches.

    I ran to each of the three approaches for the hundreds of iterations, ignored the first 30 iterations to allow allocations of memory (which caused a huge spike in runtime performance about the RT), then took the average operation time for each iteration of the loop for the remaining iterations

    Original M: 485 msec/iteration

    Updated M: 276 MS/iteration

    G: ms 166/iteration

    The changes I made to your code ".m" are:

    (1) added; at the end of each line to remove output (used for debugging)

    (2) left random code generation - used whitenoise (seems like that is what you did)

    (3) turn on the type of data highlighting the function. Noticed that the majority of data was cast in the complex, although that did not seem like you need the complex domain. The source has been function sqrt. Changed using real (sqrt (...))

    This improvement in performance by more than 40%. I believe that more can be pressed if you follow the documentation - MathScript wrote for real-time Applications.

    Then I took the MathScript you and equivalent written G leaving the algorithm as it is. This gave us the improvement of the performance of another 40 per cent in the G. updated the it is a known issue that on slow controllers, MathScript adds a penalty of 2 x to g equivalent. We are investigating this issue and may be able to fix it in a future release.

    If you are profiling the G code, you will notice that most of the time we spend in the multiplication of matrices. Unless rethink you your algorithm, I doubt that this can further improve.

    Let me know if you have any questions

    Kind regards

    Rishi Gosalia

  • 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

  • Creation of Matricies with Mathscript

    Is there a way basically to allocate the memory inside a mathscript node?  In other words, in Java or C++ you can say something like x [10]... to achieve a matrix and can complete it later.

    Hello

    In MathScript, you can use

    A = [];

    to create an empty matrix and fill it out later.

    In addition, you can use

    A = zeros (10);

    to create a matrix of 10 x 10, filled with zero.

  • Orders of MathScript

    HI all, I'm quite new to LabVIEW MathScript and have had trouble with the help of the command 'load' in the window MathScript to load the data want to sort the data in each column (4 in total) in a data file. I can do this in Matlab, simply by using the following commands:

    x = dlmread ('c:\work\plotdata\plotdata',' ');

    sortx = draw (x);

    Now the problem I'm having is that when I try to read all the data in my data file in MathScript using the dlmread command, I get the error ' error in the function dlmread in line 1. This function is not defined for the number of parameters you provided. "Using the command 'charge' produces the same error. Each columns are separated from each other by 2 spaces - which is what I've specified as above. Please advise on the appropriate method.

    Then, I am trying to sort the data in the columns and am unable to do in mathScript. I have attached a picture of the data file that I am trying to sort. Note that the image data has not yet been resolved. For the guidance of the guru...

    Hello

    I tried to create a file of test like yours and dlmread can read the data successfully in LabVIEW 8.6. I think your problem is that the file name is not correct. By default, dlmread will read the data of the .dlm file if you do not specify the file extension. As a result, your script should read 'c:\work\plotdata\plotdata.dlm '. You can specify the full name of the file including the file extension or rename your data to .dlm file.

    For sortx = (x), if the input x is a matrix, MathScript returns the sortx columns in ascending order. This must be what you expected.

    Would you please try again?

  • Chemometrics - Non-linear Iterative Partial Least Squares, MathScript and G-Native Code

    I worked with a client on a spectroscopy system and he asks me to do the analysis in components in the application I'm building for him. The current method, I found is what several people have built with MatLab scripts for least partial square. That's great and it works; However, I wanted to convert the native GCode script because I'm that guy.

    After a few days, I was finally able to get the results of the two screws is similar, but not the same thing. I was not able to find an explanation for it on the forums or elsewhere. The important thing I found is that LabVIEW breaks a little when you have a vector calculation as a ' * a, which should translate into a scalar value or a 1 x 1 matrix. When you use this value in another equation, such as the projection X'* a /(a'*a), LabVIEW works only on the first element of X'* a.

    Here, it's in the GCode with the work around to correct one ' * a result:

    It seems unusual that GCode treat a scalar result incorrectly. It was annoying, but I was able to go beyond that.

    My next question is there is some apparent rounded differences between GCode and MathScript that I was not able to explain. This difference amounts to about 1% in the data I have to analyze. I've included the project where I worked to compare the two methods. In the NIPALS_Conversion_LV.vi the left side of the block diagram has a loop structure For which is where the model is generated using the NIPALS and the right side is the application of the model. The NIPALS_Converison.vi contains the original code of MathScript where I worked with.

    Note that the difference between the two results is due to the calculation of you and matrices of B, which are related to each other because of the u. I probed the two vi extensively and everything is equal between them until the calculation of the elements in u. The equation in question is u = Y * ((Y'*t1) / |) (Y'* t1) |), even if it is expressed somewhat differently in the code.

    Any help on this would be greatly appreciated.

    Thank you

    Drew

    Drew,

    I took a quick glance to your project and for me, it seems that you have correctly translated the MathScript in its equivalent in the graphical representation.

    My first inclination on why you see this slight rounding error, is that the functions used in LabVIEW and MathScript can be different (from different DLLs). How these functions given floating point rounding may be different and spreading them error thanks to each iteration of the loop. I suspect that you notice that the error at this time in the program. If you compare every step of the script from the execution of LabVIEW and look out past 10 or if the bits of accuracy, I think you will see this error increase slightly after each step.

    If you can find a specific function during which a significant difference between the script and LabVIEW execution occurs, I'd be happy to review the functions and the differences between the LabVIEW MathScript implementations of functions.

    -Nick-

  • Why the mathscript well below matlab performance?

    Hi all

    I do the signal processing on a signal acquired with an ADC. The flow of information is roughly 10,000 x 1000 int8 Matrix per second. I'm trying to process the data at the same speed. Signal processing is done in a ".m" matlab file. The treatment is much to complicated to be coded in the G code.

    I have two choices:

    1. use matlab nodes

    2. using the Mathscript node.

    I've implemented the solution 1, but loses a lot of time just for the transfer of data between labview and matlab (matrix transfer ~ 10 MB). MATLAB is very quick to do signal processing. A faster version of this solution was to write the matrix in a bin file and pass the name of the file to matlab. It is faster (don't ask me why), but is not fast enough.

    Solution 2 sounds better, because as Mathscript is a native language, it is not necessary for the transfer. Prior to joining Mathscipt, I did the following test: run the same simple code on two solutions: calculate the fft of a matrix of 1024 x 1024 ten times (code attached).

    As a result, Matlab version node is 0. 5s compared to 1.6 s for the Mathscript node version.

    Why is the performance of mathscript so much less than the performance of the matlab node?

    If really Mathscript is much slower than Matlab, so I'm afraid I'll stay with node of matlab. Is there a better way to transfer data through files?

    Thanks in advance for your answers!

    You do not know, I can help you, but I found the same thing.

    I have a few guesses - do you use 64-bit Matlab? If so you may have noticed that MathScript runs under 32-bit LabVIEW.

    The other possibility is that Mathscript runs as a process integrated into LabVIEW, while if you use MatLab you use Simulink to communicate with Matlab in its own thread.

    Third option could simply be that Matlab is a commercial product that is much more optimized.

    Honest answer is that I don't know!

  • transposed matrix form?

    How will I know what form a table is a long section of the mathscript code? IE is a table one row or column, or a matrix. Often, I get the error that produced the home, regardless of what form, I develop controls in.

    I really need an accurate way to determine the form, rather than clamping functions transpose randomly.

    Thank you


  • How LabVIEW calculates the Euler Angles of the Direction cosine matrix?

    I am looking to clean my block diagram by converting mathematical functions LabVIEW Mathscript; However, I can't know exactly what convention of rotation is used to calculate the Direction cosine matrix Euler angles. Any ideas?

    Here is what I use now (see below)... the angle phi is the only one (of three angles) not correct as mathematical LabVIEW functions. I've also attached the .vi illustrating the calculation in two ways.

    % calculate the angles of Euler of DCM

    % "DCM" is a 3 x 3 direction cosine matrix

    Phi = atan ((DCM (2,3)) / (DCM (3.3)));

    Theta = acos (DCM (3.3));

    lb/po2 = atan2 (DCM (1,3), DCM (2,3));


  • Mapping the table matrix 2D

    I can't try to plot the graph of an output matrix, Sk since a MathScript node.

    The Sk parameter should be a way out of the matrix (12 x 1) with the length of the added step.  I can see that its fate in the form of a table 3D but can not get the graph of the function works.

    What I aim to do...

    I need to draw responses to the 12 line separate items of the Sk parameter over time.  This means that I have to post 12 separate parcels, ideally to be on the same graph with a shift on the value axis for stacking the answers (I'm not worried about the relative amplitudes since I was only interested in seeing the step responses in 12 plots).

    If someone can provide some guidance it would be greatly appreciated.

    Just right click on the tunnel exit SK and select data type "matrix of 1 d, DBL.

    (The way you slice the table at the beginning is crazy.) Why do you want to create all copies of these data for the most part redundant? Simply no autoindex on 2D and table use the table to index resized to five outings and wire the first clue to the final iteration to get five tables 1 d. You must also calculate the value connected to N for the number of columns minus four, or similar)

  • MathScript adds the row of table

    Hello LabVIEWers,

    I recently encountered a problem using the MathScript that I don't understand.  When I create a simple table of dimension 1 and then access a single element in this array, MathScript and/or LabVIEW adds an extra line in this table.  This problem appears when I add the output for the MathScript structure array and create an indicator.  A VI sample that illustrates the problem I encounter is attached.  I have also run the same code MathScript in MatLab and the issue does not seem to occur.  Is there something that I am missing? Perhaps a logical reason and explantion for why LabVIEW for this?  I searched on the web, help and forums so far.  Any help is appreciated.

    My goal is to be able to access the items in a table without changing the dimensions of the table, or to manually remove the added row.

    Kind regards

    Doug

    Hello Doug77,

    In the line where you replace the 5th element of the array, if you say public (5) = 77, LabVIEW will not add the extra line. Almost everything in Mathscript if defined as a matrix. That's why you see size as 1.11. If you try to manipulate the public in the form of a 2D picture, saying test_array (1,5), mathscript guess it must be a 2D array.

    Let me know if it helps.

  • The results of contourc in MathScript does not match

    I have a simple ".m" file which I'm trying to convert labview code by using the Mathscript node.

    The matlab code is simple as follows

    % Read image

    IM = double (imread (image_path));

    C = contourc (im, [0.8 0.8]);

    I checked the latest Mathscript node. The 'imread' and 'contourc' are built-in functions supported. So far so good. So I put the code in the node (for contours in MathScript functions, I had three options: outline, outlines, contouris.) One contour is supported by the runtime, so I chose "contour").

    BUT the result of Mathscript is inconsistent from Matlab. From Matlab, it is a matrix 2 X 126, while since Mathscript, it is a 2 X 200 matrix. I tried others two strokes and contouris as well, same result.

    SO what is happening here. How should match the original matlab code with a function "contourc" in there? Thank you.


  • It is faster to index an initialized matrix or use a tunnel auto-indexed, both inside a loop - what happens?

    WARNING: MATLAB user here.

    Note: This is a question of LabVIEW, not a matter of MathScript.  I just use MathScript to demonstrate the point.

    This is background to the particular question.

    In MATLAB if you want to calculate decent efficiency then you want previously declared tables and want the built-in functions.

    This means that it's slow:

    ICT

    for i = 1: 10000

    ENTRIES = rand;

    end

    T1 = toc

    (t1 = 0.266, so 37.6 elements/MS)

    and it's faster

    % start before the next loop, but not copy - paste with it because it slows down it waaaay

    Claire x

    ICT

    x = Zeros (10000,1);  % If not the ', 1' and then it overflows of memory to MathScript

    for i = 1: 10000

    ENTRIES = rand;

    end

    T2 = toc

    (t2 = 0.205, items so 48.8/MS)

    In MathScript, it is an improvement of 23% at run time.

    ratio = 100 *(t2-t1)/t1

    (ratio = - 23.3)

    When I use LabVIEW for the same thing, I get:

    which leads to a computation time of 269 ms for about 10 000 000 elements in a vector.  (Note that this is literally ~ 1000 x faster than MathScript).  He created elements of k ~ 37 per millisecond.

    If I change out for a created matrix indexing, then the time is strange.

    When I run it for 10 elements of k, or about 1000 times less, then he finished in approximately 30ms, or approximately 333 items per millisecond.

    When I run it for 100 k items, or about 10 x more last run and 100 x less than the previous vi, and then it ended with about 5000 ms, or approximately 20 items per millisecond.

    The best construction and replace it is running hundreds of times slower, and it is perhaps running ~ 1800 x slower.

    Here's my problem:

    One of these things is 1800 x slower than others.  Why is it reasonable?  Why is-111 x reasonable?  Here are the simple changes.

    I love that LabVIEW is literally 1000 x faster than MatLab in certain tasks.  I need to understand why, in some cases this multiplier 1000 x falls down to a 2. 4 x DECREASE.  Intuition I have is not only wrong, it's incredibly bad.  He's wasting the 1000 x multiplier of speed that I am very happy with.

    My thought:

    If I did it in assembler to nickname the first loop is as follows.

    I point to the stack, call the random number generator to get a value on the stack, incrementing my counter, check if it's 10 million, update my pointer location and iterate.

    The second loop would be as follows:

    Point battery, I write a zero, incrementing my counter, test whether it is 10 million, update my pointer location and iterate.

    then

    I will return to the beginning of the location of the stack, call the generator of random numbers to get a value on the stack, incrementing my counter, check if it's 10 million, update my pointer location and iterate.

    The report of the runtime for loops would be the time difference of calculation-writing-increment of a (pseudo) random number and THEN a zero against writing incrementing from zero.  I expect it to be somewhere between 2 x and 10 x.

    There are BONES.  Perhaps the algorithm to calculate a random number has many steps, like thousands.  Here is the difference between On-die, L2, RAM and disk.  Given enough items I would expect things to have to go through the bottlenecks and get slow.

    You have to shift registers when using him in place element structure. I don't know why, but it is much faster (and a more exact comparison) when you use the shift register.

  • repmat MathScript

    Hello!

    I tried to do the matrix * vector multiplication in the Mathscript node cross-checking, but it seems it does not work. (In Matlab only)

    If it is not possible to do, I should then repeat the vector to have the same number of rows in the matrix, but I don't know how to do either. Could someone tell me the equivalent of 'repmat' (Matlab) in the Mathscript node? To make a vector = 1, 2, 3 in 1, 2, 3 = matrix; 1, 2, 3; 1, 2, 3; ...

    Thank you!

    Gabriel

    repmat in labview mathscript node: the following syntax works:

    AUX1 (:, Ones (5,1))

  • Matrix of null space

    Hello

    I have a question about Equation.vi linear solve.

    Given a system of equations 8 to 9 unknowns, form: AX = Y, A is a matrix known 8 x 9 and X is a vector of 9 x 1 (unknown) and Y = 0. I would like to find space void of this equation system. We have 9 vectors columns each with 8 elements. Columns vectors are dependent lineary so there must be a linear combination of them. So I would like to find the X by solving for the 8 x 9 matrix null space.

    Is the linear equation solving is capable for this purpose?

    Hi D60!

    If you double-click the linear solve Equation.vi and take a look on the block diagram.

    You will see that, depending on the type of your matrix, functions at different riding are used. You can double-click on these features too, to see how it works.

    I think that the best way to get the matrix null space is the function null of the Mathsrcipt node: http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmath/msfunc_null/

    More information about the Mathscript node: http://www.ni.com/white-paper/7572/en

    Please let me know if my suggestion is useful.

    Best regards

Maybe you are looking for