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

1 回表示 (過去 30 日間)
AMRA Lab
AMRA Lab 2021 年 7 月 18 日
回答済み: Torsten 2021 年 7 月 18 日
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?

回答 (1 件)

Torsten
Torsten 2021 年 7 月 18 日
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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by