Problem in generating iterations in 3/8 simpson rule
Afficher commentaires plus anciens
I want to make simpson rule algorithm for my function for different intervals (here, 3^p), and plot the error vs p. The code below is showing error in the use of syms in 1st line and the iteration of line 9 (Itr=Itr+f(N+1)/2). Please tell what is wrong in this and how can I correct it.
syms p
N=3^p;
h=1/N;
for i=1,N;
x=i*h;
f(i)=exp(-x^2)
Itr=f(1)/2;
Itr=Itr+(3/2)*f(i);
Itr=Itr+f(N+1)/2;
end
Itr=Itr*h;
for p=1,10;
plot(p,itr)
end
Error using sym/subsindex (line 857)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 902)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in simpson3by8rule (line 9)
Itr=Itr+f(N+1)/2;
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!