# how can I investigate the effect of uncertain parameters on a bi-variate function by using color map?can I use below code?and also how can I solve the error in code?

1 view (last 30 days)
sogol bandekian on 16 May 2022
Edited: sogol bandekian on 21 May 2022
%monte carlo simulation
sigma=[2 1;1 3]
mu=[1,2]
%initialization
N=100 %number of trail
counter=0
%run the simulation
for i=1:N
%function %generate random numbers
x=2*randn(1,N);
y=randn(1,N);
z=randn(1,N).*sigma+mu; %repmat(mu,10,1) + randn(10,2) %Z = sqrt(1 - X.^2 - Y.^2); %in z ,y and x should be included
if w == x(x.^2 + y.^2 + z.^2 <= 1) %check if occur
counter=counter+1 %find the number of occurance
plot3(x(i), y(i), z(i), '.r')
else
plot3(x(i), y(i), z(i), '.b')
end
end
%%%%%%%%%%%%%%%%%%the error is:Matrix dimensions must agree.%%%%
histogram(w)
histfit(w)
mu=mean(x)
sigma=std(x)
PDFNormal=normpdf(x,mu,sigma) %return as a vector %x is function of system
plot(w,PDFNormal)
gm = gmdistribution(mu,sigma)
pdf(gm,x)
fsurf(@(x,y)reshape(pdf(gm,[x(:),y(:)]),size(x)),[-10 10])
Probability=counter/N
disp(['The estimated value is ' num2str(Probability)])