I have a problem with integration "Error using / Matrix dimensions must agree"
Afficher commentaires plus anciens
syntax is here:
clc;clear all;close all;
m=input('input a value');
x=linspace(1,2,m);
%function
f=(x+(1/x)).^2;
%real value of integral
ff=@(x)(x+(1/x)).^2;
RV=integral(ff,1,2);
%Solution with numerical method (Trap method)
IT=Trap(x,f,m)
ybh=100*(abs(RV-IT)/RV
function IT=Trap(x,f,m)
IT=(x(m)-x(1))*(f(1)+f(m))/2
return
end
Why this isnt working?
ERROR:
input a value2
Error using /
Matrix dimensions must agree.
Error in odev (line 5)
f=(x+(1/x)).^2;
Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!