Using recursive function with combination of n variables(each variable being an array of numbers)!!

1 Ansicht (letzte 30 Tage)
I have 5 variables; x, y, z, r and s.
each of these variables contains an array of data. Eg. x=[10, 20, 30, 40, 50, 60], y=[2,3,4,5,6], z=[0.5, 0.75, 1, 5, 10], r=[50, 220, 1100], s=[2, 10, 100]
conditions for the simulation to be met; x/y <= 10; r/s>50
How to run simulation for the various combination of this data set, in a single go?

Antworten (1)

Torsten
Torsten am 18 Jul. 2021
mx = size(x,2);
my = size(y,2);
mz = size(z,2);
mr = size(r,2);
ms = size(s,2);
[X,Y,Z,R,S] = ndgrid(1:mx,1:my,1:mz,1:mr,1:ms];
product = [x(:,X),y(:,Y),z(:,Z),r(:,R),s(:,S)];
product(product(:,1)./product(:,2) > 10 | product(:,4)./product(:,5) <= 50) = [];
product

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by