3-d plot generated from simulations

1 回表示 (過去 30 日間)
Angelavtc
Angelavtc 2021 年 6 月 2 日
コメント済み: Angelavtc 2021 年 6 月 3 日
Hi all,
Could someone please tell me how to generate a graph like the one in the figure below?
My idea is that I have a variable X that I simulate 1000 times with a normal distribution to which I want to vary the mean (from 75 to 125) and the standard deviation (from 1 to 50). From the different values of X obtained, I would like to calculate the Y variable. My idea is to make a graph where the x-axis is the different mean values, the y-axis is the different standard deviation values from X, and the Z-axis is the expected value (Z) obtained for the Y function.
n=1000; %number of sample
X = normrnd(100,40,n,1); %Demand Simulation,here I want to change the mean and the std. deviation
Y=0.3*((X/10).^(2));
Z=mean(Y);
Thank you very much for your help!
  21 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 6 月 3 日
With using flip on a matrix, you need to be aware of whether you are flipping along the rows or column. flip(Y) or flip(Y,1) flips the rows, but flip(Y,2) flips the columns. Try the latter and you'll see a difference.
Angelavtc
Angelavtc 2021 年 6 月 3 日
Ok! Thanks for everything @Scott MacKenzie I really appreciate all your help and wish you the best :)

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

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 2 日
n = 1000;
iMax = 50;
jMax = 50;
myArray = zeros(iMax, jMax);
for iIdx = 1:iMax
for jIdx = 1:jMax
myArray(iIdx,jIdx) = mean(0.3*((normrnd(iIdx,jIdx,n,1)/10).^(2)));
end
end
[X, Y] = ndgrid(1:iMax, 1:jMax);
surf(X, Y, myArray');
xlabel('X'); ylabel('Y'); zlabel('Z');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by