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.
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.
03-29-2015 09:20 AM - edited 03-29-2015 09:23 AM
Hello everyone,
what's the easiest way to add all the elements of a single row or column of a matrix given the matrix and the number of that row/column on LabVIEW ? The output should be a number for each row or column.
Solved! Go to Solution.
03-29-2015 10:15 AM
I'm assuming you are very new to LabVIEW, otherwise you would know about For loops, indexing, and the Array functions. In many programming languages, a "matrix" is just a multi-dimension array, but in LabVIEW, it is a different representation of a multi-dimension array.
If you are really working with a LabVIEW Matrix, the easiest way might be to convert the matrix to a 2D array and use the various Array functions to do the work. Note that once you have the row or column isolated as a 1D array, there is a function on the Numeric palette that will add the array elements for you (so you don't need the For loop to do that).
P.S. -- I underlined "might be", above, because I've never actually used LabVIEW's Matrix functions, but have stuck with 2 (or 3, or 4) dimension arrays.
Bob Schor
03-29-2015 10:18 AM - edited 03-29-2015 10:18 AM
Do you have an arry or a matrix? In LabVIEW they are different datatypes. The matrix datatype is typically used only when the specialized linear algebra functions are needed.
To do what you ask with the much more commonly used array datatype, use Index Array (array palette) followed by Add Array Elements (Numeirc palette).
Lynn
03-29-2015 12:40 PM - edited 03-29-2015 12:41 PM
Thank you both for the quick response and the helpful tips.
Actually my problem was separating each row or column, to be able to use the "add array elements" function. But I realized it can be done automatically once I wire the matrix array through an auto-indexing tunnel of a loop. Then i could simply transpose the matrix to be able to work with rows only or column only.
Arij
03-29-2015 01:32 PM
Arij,
You still have not indicated whether you are using an array or a matrix.
The Transpose should be outside the loop.
This will give you the sums of all rows and all columns.
These are basic LabVIEW constructs and functions. If you do not understand the concepts, please look at the on-line tutorials.
Lynn
03-29-2015 01:49 PM
I'm using a matrix, and I did place the transpose function outside the loop, and got pretty much the same block diagram you have there.
Thank you though
03-29-2015 02:01 PM
Yes, for this kind of code it is irrelevant if you have a 2D array or a matrix. same difference.
Is your problem solved?
03-29-2015 04:08 PM
yes it is.
03-29-2015 07:10 PM
It is helpful, as the Original Poster, for you to mark the response that you consider "The Solution" as The Solution (in case later visitors with similar questions find your post).
BS
03-30-2015 03:25 PM
Oh, I didn't know this feature mattered. As you can see, I'm new to labview, AND to this community. But i like it, and i'll do as you said.