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: 

for loop to index array

Solved!
Go to solution

I have a 4x5 matrix 

I want to take out each col (4x1) and convert that into (2x2) now I want to get the max elements array till now  

 

confused in RED BOX

 

gptshubham595_1-1610617823696.png

 

 

0 Kudos
Message 1 of 6
(1,374 Views)

You would probably get better help if you put more time into asking your questions more clearly and *thoroughly*.

 

I for one usually avoid threads where questions are unclear or ambiguous because they often lead to a big waste of time.   It's frustrating to spend time on explanations and answers, only to find that they're either ignored or irrelevant because the original poster didn't take the time to be more clear or provide important context.

 

Help us out.  Help us help you.  Describe what you're doing and why.  Give some example data as input and show us what you want as output.  And again, explain the purpose.  Many posters here get stuck part way along the wrong path and wind up asking a too-narrowly-focused "wrong question".   Often the best solution isn't to help them move farther down the wrong path.  Rather, it's to identify a different better path altogether.

 

 

-Kevin P

 

P.S.  The first most obvious "red box" problem is that none of your matrix data or operations are inside the loop.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 6
(1,356 Views)

If it's just the red box you're confused about (as am I as I look at it, what are you doing?), the loop should encompass both your array manipulations. Then you remove the Index array, as if it's Autoindexed you'll get 1 row at a time inside the loop.

max values.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 6
(1,347 Views)

Thank You, I will try to improve the writing of the post further.

 

gptshubham595_0-1610624629801.png

this is my main intention I have shown this without for loop and only for 0th index and 1st index, I want to do it till 4th index 

 

 

This is I tried but was not able to get an updated max matrix RED BOX

 

gptshubham595_0-1610627228213.png

 

 

0 Kudos
Message 4 of 6
(1,337 Views)
Solution
Accepted by gptshubham595

If you want to convert a 4x5 array into 5 2x2 arrays and then take the maximum value by index of those 5 arrays...

Then I would take the maximum value of each column in the 4x5 array and then reshape the 4 resulting values into a 2x2 array:

 

snip.png

 

RamonG_0-1610627002890.png

 

Message 5 of 6
(1,321 Views)

I just gave kudos to RamonG for posting the exact same code I was about to post (so of course I like it), only quicker.  The transpose allows for auto-indexing, and there's no need to reshape until after the loop.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 6 of 6
(1,310 Views)