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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

calculate all combinations using FOR loop

EP_10906526
4-Participant

calculate all combinations using FOR loop

hello community.

need some support. 

im trying to calculate all possible combinations of Voltage * Current 

need to display all combinations in a matrix with only 1 column

in this case have 3 voltages and 3 currents

matrix result should be of 1column and 9 rows. 

 

this is what I have up to now, but not been able to display each iteration. 

EP_10906526_0-1715012398877.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

6 REPLIES 6

MartinHanak_0-1715015823828.png

 


Martin Hanák

A slightly shorter version than what Martin posted.  We don't need to loop through one vector if we vectorize.  Not better, just another way to go about it.

2024-05-06_12-46-41.jpg

Two other ways - taking advantage of a DOE feature. fullfact provides the combinations of subscripts needed for every combination.  Personally I'd just use nested for's since it's easier to understand and more flexible.  But it's fun to explore new ways.  (Note: answer sequence changes from other posts)

2024-05-06_14-06-30.jpg

ppal
17-Peridot
(To:EP_10906526)

ppal_0-1715030041815.png

 

Hi,

The simplest method using the power of Prime

Capture.JPG

Cheers

Terry

LucMeekes
23-Emerald III
(To:EP_10906526)

Here's another approach:

LucMeekes_0-1715032529959.png

with:

LucMeekes_1-1715032547777.png

and

LucMeekes_2-1715032566347.png

and

LucMeekes_3-1715032586959.png

we get:

LucMeekes_4-1715032597351.png

and with

LucMeekes_5-1715032620824.png

we get

LucMeekes_6-1715032634239.png

and with

LucMeekes_7-1715032882955.png

we get

LucMeekes_8-1715032905176.png

you could even

LucMeekes_9-1715033027268.png

to get

LucMeekes_10-1715033042313.png

Success!
Luc

Top Tags