ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix

Solved!
Go to solution

Hello, 

 

If I have a matrix like the attached file (1.csv),

I want to divide each element by a certain number for example 4 and generate a new matrix to be like the attached file (2.csv).

I make code like the attached. But I see it not practical if I  want to change the element (Numeric) and with the large matrixes. 

Do you have any ideas! 

Download All
0 Kudos
Message 1 of 6
(2,735 Views)
Solution
Accepted by BaJa_2020
0 Kudos
Message 2 of 6
(2,724 Views)
Solution
Accepted by BaJa_2020

Some comments about your code:

 

  • You have a 2D array, not a matrix. (In LabVIEW, a matrix is a special datatype designed for linear algebra).
  • If your inputs are integers and divisible by the numeric, there should NOT be any orange. It should be all blue! Try it!
  • "Index array" is resizeable. You don't need 13 instances!
  • There is no reason for your local variable!
  • If you can describe the problem in one paragraph, something is wrong if it takes a screenful of code. Look at my solution above.
  • Not sure why you have a selectable path, but a hardwired file name. Seems too rigid.
  • Code needs to be scalable. My example works for any size inputs and values. Your code would be impossible to scale to an input with much larger arrays.
  • I recommend you look at some basic tutorial about array operations.
  • Good luck!
0 Kudos
Message 3 of 6
(2,707 Views)

Thank you, I will follow your advice. 

another inquiry: 

I I am going to make some calculation for the output array. Then I would like to back it to the original dimensions.

I should collect every 4 (element) together. 

in another way.. dose it possible to reverse this code?

 

0 Kudos
Message 4 of 6
(2,672 Views)

That depends on the calculations. Are all sets of four rows still identical after the calculation?

0 Kudos
Message 5 of 6
(2,667 Views)
Solution
Accepted by BaJa_2020

Here's one possibility:

 

altenbach_0-1598334720185.png

 

 

altenbach_0-1598334858309.png

 

0 Kudos
Message 6 of 6
(2,664 Views)