how to write symbolic integral
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brucedai003
le 22 Mai 2017
Commenté : Star Strider
le 22 Mai 2017
I want to use the symbolic function `int` to find the indefinite integral of the function 4*x^2+3, and the definite integral from x = -1 to x = 3. here is my approach, but got an error:
int(4*x^2+3)
int(4*x^2+3, x = -1..3)
>> problem8
Undefined function or variable 'x'.
Error in problem8 (line 1)
int(4*x^2+3)
I followed the documentation of int to write these expressions, but I don't know why it doesn't work, just new to symbolic functions in MATLAB.
Then I reasearched, and added syms x in the first line.Now the first expression works, but the second definite integral still doesn't work.What should I do? Now the error is
syms x
int(4*x^2+3)
int(4*x^2+3, x = -1..3)
>> problem8
Error: File: problem8.m Line: 3 Column: 16
The expression to the left of the equals sign is not a valid target for an assignment.
It's quite awkward of the syntax x = -1..3, not anything like what I learnt in MATLAB.
0 commentaires
Réponse acceptée
Star Strider
le 22 Mai 2017
Try this:
syms x
int(4*x^2+3)
int(4*x^2+3, x, -1, 3)
ans =
(4*x^3)/3 + 3*x
ans =
26/3
See the documentation for the Symbolic Math Toolbox int function for details.
2 commentaires
Star Strider
le 22 Mai 2017
My pleasure.
Interesting. That syntax is not in the R2017a documentation. It could be in the MuPAD documentation. I did not look there.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!