when I try to plot the variable defined by syms, matlab reports errors
Mostrar comentarios más antiguos
syms f(x1,x2);
f(x1,x2) = 2*(exp(-x1.^2)-exp(-x2.^2)).^2./(erf(x1)-erf(x2));
t=zeros(1,10);
for i = 1:200
x=randn(1,10);
y=randn(1,10);
t=t+f(10*x,10*y);
end
plot(1:10,double(t))
错误使用 mupadmex
Error in MuPAD command: Division by zero. [_power]
Evaluating: symobj::double
出错 sym/double (line 523)
Xstr = mupadmex('symobj::double', S.s, 0);
Respuestas (1)
Walter Roberson
el 22 de Mzo. de 2022
Editada: Walter Roberson
el 22 de Mzo. de 2022
0 votos
You are using erf(). If you use erf(5.76) or more than the result is within round-off error of 1. But you are passing in 10*randn and randn is above 0.576 a lot of the time — roughly 1/3 of the time. So two randn both being above that would occur about 1/9 of the time. About 1/9th of those 200*10 = 2000 samples you generate will both have erf(10*x) that is 1.0 to within round-off. Now subtract those 1.0 values to get 0. And you divide by 0.
1 comentario
yu yu
el 22 de Mzo. de 2022
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!