Info

この質問は閉じられています。 編集または回答するには再度開いてください。

can anyone help me ?

2 ビュー (過去 30 日間)
diadalina
diadalina 2019 年 6 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
here is a code matlab of one degree differential equation, i want to plot the error method for different values of N, can anyone help me
  2 件のコメント
Geoff Hayes
Geoff Hayes 2019 年 6 月 2 日
diadalina - please clarify what you mean by i want to plot the error method for different values of N. Does your code do some or all of this already? If not, where should this happen in your attached code?
diadalina
diadalina 2019 年 6 月 2 日
the error wich is equal to norm(the approchsolution-the exactsoltuion), i want to show the accuracy of the numerical method used here , my code doesn't work correctly !!

回答 (1 件)

Stephan
Stephan 2019 年 6 月 2 日
編集済み: Stephan 2019 年 6 月 2 日
clear all;
clc;
close all;
N=[100,200,300,400];
hold on
for k=1:numel(N)
%%les données mathématiques
t = 0:1/(N(k)-1):1;
%les conditions initiales
c0=0;
%%résolution de notre système
[~,Y]=ode45(@systest,t,c0 );
sol_exacte=t.*exp(t);
subplot(2,1,1)
plot(t,Y(:,1),t,sol_exacte,'+')
legend('sol-app','sol-exacte')
err(k)=norm(Y(:,1)'-sol_exacte)
e=err(k);
end
hold off
subplot(2,1,2)
semilogy(N,err,'ob--')
legend('error')
function F=systest(t,Y)
F(1,1)=Y(1)+exp(t);
end

Community Treasure Hunt

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

Start Hunting!

Translated by