Skip to main content
8-Gravel
September 13, 2024
Solved

how to create 'if statement' for vector

  • September 13, 2024
  • 2 replies
  • 1278 views

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

Best answer by AlanStevens

You don't need an if statement:

minmax.png

 

2 replies

19-Tanzanite
September 13, 2024

You don't need an if statement:

minmax.png

 

8-Gravel
September 13, 2024

this works for me. Thank you Alan! 

25-Diamond I
September 13, 2024

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

Werner_E_1-1726229791473.png

 

 

23-Emerald V
September 13, 2024

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