I was calculated using the Simpson 1/3 rule numerical method, why my running results doesn't appear in the command window?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear all;
clc;
%input data
a=0;
b=2;
c=1; %centre
f_2=(-1/4*(2)^4)-(1/3*(2)^3)+(5/2*(2)^2)+3*2;
f_0=(-1/4*(0)^4)-(1/3*(0)^3)+(5/2*(0)^2)+3*0;
i=(f_2)-(f_0); %exact
x0=0;
xa=(-x0^3-x0^2+5*x0+3);
x1=0.5;
xb=(-x1^3-x1^2+5*x1+3);
x2=1;
xc=(-x2^3-x2^2+5*x2+3);
ai=((b-a)/6)*(xa+4*(xc)+xb); %main equation
et=(i-ai)/i*100;
i created my own script. the result appear on the workshop, but why it dosen't appear on command window?
please tell me where did i go wrong and how to fix it
0 commentaires
Réponses (2)
ScottB
le 27 Nov 2023
A semi-colon at the end of a line suppresses display of the result.
0 commentaires
Torsten
le 28 Nov 2023
Use
ai=((b-a)/6)*(xa+4*(xb)+xc) %main equation
instead of
ai=((b-a)/6)*(xa+4*(xc)+xb) %main equation
clear all;
clc;
%input data
a=0;
b=2;
c=1; %centre
f_2=(-1/4*(2)^4)-(1/3*(2)^3)+(5/2*(2)^2)+3*2;
f_0=(-1/4*(0)^4)-(1/3*(0)^3)+(5/2*(0)^2)+3*0;
i=(f_2)-(f_0) %exact
x0=0;
xa=(-x0^3-x0^2+5*x0+3);
x1=0.5;
xb=(-x1^3-x1^2+5*x1+3);
x2=1;
xc=(-x2^3-x2^2+5*x2+3);
ai=((b-a)/6)*(xa+4*(xb)+xc) %main equation
et=(i-ai)/i*100;
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!