04-29-2017 10:53 AM - edited 04-29-2017 10:55 AM
If you don't want to mess with what you already have, you can just collect all those outputs using "build array" as shown below: This makes a 2D array of 3x3.
In your case, you would want seven 'build array' nodes, each with six elements.
For the first one, wire all the elements for the first row in your array. Then, in a separate 'build array', wire the six elements for the second row, etc.
This will give you six 1D arrays, representing the six rows. Then, wire each of these to another 'build array' and make sure it is not set to 'concatenate'.
That'll give you one 2D array of 6x6.
(But I still think you'll be much better off restructuring your program, and it's not that much work. I'd be happy to do that, if you can save your VI for an earlier version of LV, so I can open it.)
04-29-2017 11:00 AM
Thank you man, will read that.
Try to open this one, it is from Labview 2012.
04-29-2017 11:20 AM
Sorry, that's still in version 2014. I need 2013 or earlier.
04-29-2017 11:34 AM
@OzanGungor wrote:
Thank you man, will read that.
Try to open this one, it is from Labview 2012.
Currently, all inputs to your formula node are diagram constants. Which one's are actually variable in the real program?
As others have said, you would make your life so much easier by operating on arrays to begin with. These seems to be a lot of repetition and duplication.
I am not going to dissect your "formula tome" (:D). Do you have a link to a website that shows the calculation you are trying to do?
04-29-2017 12:12 PM
@OzanGungor wrote:
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?
Looking at your Duzkinematic attachment, it reminds me of rotation matrices, but because it is all in isolated formula lines, it is difficult for me to know what it is you are trying to compute. I'm guessing that if you told us what you really wanted to do, one of us might be able to suggest some matrix functions that would (a) keep the elements arranged in "natural" orders (i.e. it is easier to express a 3D vector as an "array of three" vector, V1, than as three scalar variables, X1, Y1, and Z1, and to express a rotation matrix as a matrix M1 rather than three vectors). Some of us (myself, included) have had experience working with rotations and translations and "know the math" ...
Bob Schor
04-29-2017 06:46 PM
So, since it actually makes more sense for me to explain what I was trying to do with that crazy vi that I shared, here it goes.
I'm trying to calculate the forward kinematics of a Stewart Platform which is a 6 axis parallel robot.
I have a Matlab Script file that contains all the formulas and my calculation as a reference, but as I just learned, I also have to do it in Labview and don't have too much time. That was the reason why I tried to solve everything in a day, in a text base code 🙂
I have a platform which has initial position, initial leg lengths, leg attachment points etc... These were the inputs and Jakobien matrix was the output I have tried to calculate.
Couldn't upload matlab file since .m file format is not supported.
04-29-2017 07:29 PM - edited 04-29-2017 07:35 PM
Well, I'm sure you're the only person here who has ever been forced to throw together a hastily composed program based on someone else's code. 🙂
Really, your originally code isn't bad. It's just that it doesn't really take advantage of all the best practices that you could be using. But it certainly could be a lot worse. You could have used one case structure with 36 different cases, or many worse and more confusing ideas. Your code, at least, is very straight-forward. So you shouldn't feel bad about that.
To answer your original question: There are two ways to do it, without messing up what you already have. The first, as I already suggested, is to just collect all those outputs into 1D rows, and then combine those into a 2D array. For that, all you need is seven 'build array' nodes, and a bunch of wires.
The other approach, which I think you were asking for in the first place, is to construct the array inside the Formula Node.
To do this, first create the 2D array using a statement: "float ArrayName [6][6];". (Note that Labview use double brackets: [i][j], instead of commas inside the brackets: [i,j].)
Then, inside the formula node, every time you have a result that you want to place into the array, you just assign it as such: "ArrayName[i][j] = x+y+whatever;"
In this case, i and j will run from 0 to 5, yielding a 6 by 6 array.
Then, you create an output on the formula node called "ArrayName" and this will be a 2D array.
Here is a crude example showing a 2x2 array:
I shall go to bed tonight mourning the fact that I still haven't been able to access your code... but it looks to me that you have a straight-forward list of 36 calculations, so all you'd have to do is change the output variable from 36 separate variables, to one array variable containing 36 values. I hope that helps.
04-29-2017 07:42 PM
Can you provide a description (in text) of the equation(s) you are trying to compute? It's OK to provide a link to a reference with the appropriate equations (but indicate which one you are trying to evaluate). I'm looking for a matrix or vector equation, not a "component-wise" list of 36 equations ...
Bob Schor
04-29-2017 07:53 PM
@OzanGungor wrote:
Couldn't upload matlab file since .m file format is not supported.
Unless I'm very mistaken, a Matlab ".m" file is just pure text. I think you can attach any file type (certainly one can attach .zip, .vi, .png, .jpeg), but if all else fails, you can replace .m with .txt, or Zip it up ...
Bob Schor
04-30-2017 03:36 AM
I wasn't able to reach my computer last night, that's why I couldnt upload it in text file or save it in an earlier version. Here you can find both. Hope it works.