3-d plot generated from simulations
1 view (last 30 days)
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
Thank you very much for your help!
Scott MacKenzie on 2 Jun 2021
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)));
[X, Y] = ndgrid(1:iMax, 1:jMax);
surf(X, Y, myArray');
xlabel('X'); ylabel('Y'); zlabel('Z');