Info

此问题已关闭。 请重新打开它进行编辑或回答。

Help limiting my Monte Carlo Solution

2 次查看(过去 30 天)
Mike
Mike 2014-3-16
关闭: MATLAB Answer Bot 2021-8-20
Hello,
I have to write a code to determine a Monte Carlo solution for a PDE problem. The range goes from zero to pi and the limiting factor is the sin wave. My problem that i am experiencing is that my current code stops at on and not the limit of the sin wave. Can someone take a look at the code and see where i made my mistake?
clear; clc;
n = 1000;
x = linspace(0,1,n);
Xinside = [];
dist_X = [];
figure(1)
clf;
syms p
bc = sin (p);
Range = [0 pi];
h = ezplot(bc,Range);
hold on
distance = zeros(0,1,n);
for t = 1:n
a = 0;
b = 1;
Xn = a + b*rand();
Xn(t) = (Xn + Xn)<=1;
plot(Xn);
%distance(t) = sum(distance(1:t) <=1);
%est_pi = 4*Xinside(1:t)./(1:t);
%plot(est_pi);
ylabel('estimation')
xlabel('iteration')
end
hold off

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by