3-d plot generated from simulations

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by