From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create an Array from Formula Node Output Values

Solved!
Go to solution

Hello All,

 

I'm pretty new to Labview and looking for your help.

I have a formula node that has 36 output values and I would like to store them in a 6x6 Matrix. How to do that?

 

Thanks in advance.

0 Kudos
Message 1 of 33
(5,999 Views)
  • Attach your VI so we can better understand what you are trying to do (your explanation is too terse to be of much use).
  • There is almost surely a better (meaning "cleaner", "more logical", "more self-documenting") way to accomplish whatever you are trying to do than a mysterious "Formula Node".
  • The Reshape Array function can change a 36x1 array into a 6x6 array.  It can be found on the Array Palette (the logical place to look for an Array function).  To learn how to use it, right-click the function and choose Help.  Read the Help description.

Bob Schor

Message 2 of 33
(5,963 Views)

I have attached the VI. 

I have 36 outputs that are calculated based on the formulas and given input values inside the formula node. I would like to use that 36 output values to make a single 6x6 matrix, each output value as an element of a matrix, j11 to j16 first row, j21 to j26 second row and so on...

 

J11,J12,J13,J14,J15,J16,

J21,J22,J23,J24,J25,J26

........................................

J61,J62,J63,J64,J65,J66

 

 

0 Kudos
Message 3 of 33
(5,960 Views)

Certainly there is a better way!

nav.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 33
(5,954 Views)

Looking at the picture makes me really want to debate your signature, but then I opened the VI, and sure enough... Your response is really all that can be said.


GCentral
0 Kudos
Message 5 of 33
(5,950 Views)

I'm already pretty amazed by the help but I guess things work like this in here.

 

It's been a few days I've started using Labview, deeply sorry to hurt your eyes...

 

Here is my new beautiful VI. I would like to create a matrix with the calculated values. How to do that?

 

0 Kudos
Message 6 of 33
(5,944 Views)

I can't open or see your VI, but the image shown above is definitely not the right way to do it.

 

 I always try to use the structure of the data to guide the structure of the program. If you want results in a 2-D array, it's good to use 2 nested loops. You want the results to be 6x6, so each loop should run six times.

 

 After you've picked the structure, you should ask two questions: (1) What part of the calculation is the same for each element?  (2) What part is different?

 

The part that is the same should be on the inside of the loop. The parts that change for each iteration should be on the outside. In this case, I didn't wire the "N" values for the loops. Instead, I use the array structure of the input constants to tell the loop how many times to run.  Notice that the "a" constants index on the inner loop and the "b" constants index on the outer loops.  

 

So the first row uses b[0] for all six values of a (a[0], a[1], etc.)  The second row uses b[1] with all six values of a, and so on.

 

By using indexing outputs on two loops, it automatically creates a 2-D array of 6x6.

 

Array Output.png

 

I hope this helps.

 

If you can save your original (or next iteration) for LV 2012, I could help you more.

 

0 Kudos
Message 7 of 33
(5,890 Views)

Apologies for the earlier response.

 

I think that the summary would be something like this: If you want to write the code in LabVIEW, there are likely more direct methods than implementing the code in a box containing text-base code, then outputting an enormous number of wires.

 

For some of the calculations you're carrying out, there are simple(ish) mathematical representations that do the same thing - for example, it appears that the first block is a matrix rotation, which can be carried out by multiplication of two matrices. LabVIEW contains tools to manipulate matrices (under the array palette) and so doing the calculation in more native LabVIEW code might be easier, both to code and to read.


GCentral
0 Kudos
Message 8 of 33
(5,939 Views)

I responded earlier, but it looks like my post was deleted. Not sure what happened.

 

Could you save your VI in an earlier version of LabVIEW so I can work with it?

 

In my earlier post, I suggested using the structure of the data to guide the structure of the program. If you want the output to be a 2D array of 6x6, it makes sense to use 2 nested loops that each run six iterations.

 

Below is a simple example:  The "a" constants iterate on the inner loop and the "b" constants iterate on the outer loop. As a result, the formula node gets all possible combinations of "a" and "b' inputs. Indexing on both loop outputs creates a 2D array.

 

Array Output.png

0 Kudos
Message 9 of 33
(5,926 Views)

I have a lot of pages of Matlab Script code so trying to make them run in Labview as well. I know there would be plenty more sophisticated ways to do it but that's another thing I guess.

I just want to put that already calculated values in a matrix, is that possible?

0 Kudos
Message 10 of 33
(5,925 Views)