Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Help limiting my Monte Carlo Solution

1 visualización (últimos 30 días)
Mike
Mike el 16 de Mzo. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by