Definite Integration (using MatLab Grader)
Show older comments
Hi i'm new to this program so i'm not really used to it.. i have an assignment due this week and i was hoping if someone can help me figure out what's wrong with my code.
Here is my code:
syms x;
f=@(x) int(sin(x) + x.^3 - exp(x) , [0 3]) ;
% #1 Part a
F1= - cos(x) + (x.^4)./4 - exp(x)
N1a= F1, 0 % see the hint above
% #1 Part b
N1b= F1, 3
% #2 Part a
f2=@(x) int(2./(1+x.^2) , [0 sqrt(3)]) ;
F2= 2.*atan(x)
N2a= F2, 0
% #2 Part b
N2b= F2, (sqrt(3))
My output (what i get when i run the code) is this :
F1 =
x^4/4 - exp(x) - cos(x)
N1a =
x^4/4 - exp(x) - cos(x)
ans =
3
N1b =
x^4/4 - exp(x) - cos(x)
ans =
0
F2 =
2*atan(x)
N2a =
2*atan(x)
ans =
1.7321
N2b =
2*atan(x)
ans =
0
I'll attach the question and what i get wrong:
Answers (1)
Walter Roberson
on 9 Feb 2019
You have
N1a= F1, 0 % see the hint above
In MATLAB, this means:
Assign the expression in F1 to the variable N1a. Then display the result of the calculation to the user in the form
N1a =
(whatever the value is goes here)
Then calculate the result of executing the number 0. Then display the result of the calculation to the user in the form
ans =
0
The question hints that you should use subs()
Categories
Find more on Evaluation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!