cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

how to create 'if statement' for vector

NA_11204287
1-Newbie

how to create 'if statement' for vector

Hi all, I've created a vector value as shown below 

NA_11204287_0-1726226271301.png

 

does anyone know how to create an 'if statement' to get the min/max results for these two vectors?

NA_11204287_1-1726226284485.png

 

Your help is kindly appreciated

3 REPLIES 3

You don't need an if statement:

minmax.png

 

Werner_E
25-Diamond I
(To:NA_11204287)

Similar to my suggestion in your other thread (pass/fail) you could use vectorization

Werner_E_1-1726229791473.png

 

 

StuartBruff
23-Emerald II
(To:Werner_E)

I'm sorry, I couldn't help it.  I just had to generalize the problem.  What if I had more than two vectors, I thought, or even multiple arrays of differing lengths and column sizes?  Fortunately, this is an exercise in cat-skinning.  Here's one method that pays homage to my dislike of explicit iteration.  It's not totally functional because I thought such an approach would make the technique more obscure.

 

2024 09 13 A.png

 

And now the rubber of the functions meets the tarmac of the data ...

 

2024 09 13 B.png

 

Seems to work, as did a few nst2mat test cases using arrays of differing row and column sizes (see worksheet).

 

Stuart

Announcements

Top Tags