Matlab integral funtion error
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leon Ellis
am 4 Aug. 2021
Beantwortet: Pere Garau Burguera
am 4 Aug. 2021
Hi, I can't seem to get the integral function to work correctly.
syms x
z=1/(3-1)
f=@(x)(x.*exp((x.^2)-1))/sin(x)
fi=integral(f,1,3)
This is my code, however the integral function keeps giving errors and I am unable to fix the problem. Could someone please help? Thanks in advance!
0 Kommentare
Akzeptierte Antwort
Rik
am 4 Aug. 2021
The error tells you that you need to make sure f outputs the same size as the input.
f=@(x)(x.*exp((x.^2)-1))./sin(x);
% ^
% you forgot this one
fi=integral(f,1,3)
0 Kommentare
Weitere Antworten (2)
Pere Garau Burguera
am 4 Aug. 2021
The solution is given in the error message, you should use
fi=integral(f,1,3,'ArrayValued',true);
Cheers,
Pere
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!