Why is my error not exactly 0
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wrote a very simple upwind difference scheme for the equation
with
, but for some reason the error is not exactly 0.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1668061/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1668066/image.png)
%u_t+u_x=0
space=[0.01,0.005,0.0025,0.00125];
error=zeros(size(space));
for j=1:size(space,2)
dx=space(j);
dt=dx;
u=sin(0:dx:1);
n=size(u,2);
T=1/dt;
for i=1:1
ul=[sin(-dx-dt*(i-1)),u(1:(n-1))];
u=(1-dt/dx)*u+ul*dt/dx;
end
error(j)=norm(u-sin((0:dx:1)-dt),1)/n;
end
0 commentaires
Réponses (1)
Image Analyst
le 13 Avr 2024
error is a built-in function. You must not use it as a name for your variable.
Does the FAQ answer your question?
0 commentaires
Voir également
Catégories
En savoir plus sur Eigenvalue Problems dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!