Monte Carlo Simulation Result Tabulation

I am performing a Monte Carlo simulation for 2 soil properties which each having a defined range:
  • Poisson's ratio (PR): 0.20<=PR<=0.50
  • Young's Modulus (YM): 2<=YM<=250
I want to run this simulation to generate random values for the 2 variables 1000 times and then tabulate the results to show the 1000 combinations of variables. The table would roughly look like:
PR YM
0.23 101
0.46 204
...... .......
I'm not too sure how to write the variables into the table.
N = 1000;
for n = 1:N
% generate a set of random numbers x(0.2, 0.5)
PR = rand(2,5)/10;
YM = rand(2,250);
end

1 件のコメント

Omoniyi Tope
Omoniyi Tope 2020 年 11 月 15 日
Thank you for the explanations

サインインしてコメントする。

 採用された回答

Jeff Miller
Jeff Miller 2019 年 10 月 12 日

1 投票

% rand(2,5) doesn't do what you seem to think. Try this
% (with a little extra code that might help you see how to do this in general):
N=1000;
minPR = 0.2;
maxPR = 0.5;
PR = minPR + rand(N,1)*(maxPR - minPR);
minYM = 2;
maxYM = 250;
YM = minYM + rand(N,1)*(maxYM - minYM);
finalTbl = table(PR,YM);

4 件のコメント

Omoniyi Tope
Omoniyi Tope 2020 年 11 月 15 日
I tried to run this code but it keep giving me
Undefined function 'table' for input arguments of type 'double'.
Please what am i doing wrong sir?
Jeff Miller
Jeff Miller 2020 年 11 月 15 日
Probably you are running an older version of MATLAB that does not support the 'table' data type.
Omoniyi Tope
Omoniyi Tope 2020 年 11 月 16 日
I am using the 2013 version of matlab. How then should i have put it if that is the case?
Jeff Miller
Jeff Miller 2020 年 11 月 16 日
Just use PR and YM for whatever you want to do with them. It is not essential to put these variables in a table--that was just a convenient data structure that the original poster wanted to use.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by