Can someone help me? i think there's something wrong with my code..
Show older comments
It says that xL and xR of both equations are wrong... and the outputs; some are -ve and some are +ve.
% Part a
f=@(x) (x.^3-3*x.^2-4*x+12)/(x-2);
xL=[1.999 1.9999 1.99999 1.999999];
xR=[2.0000001 2.000001 2.00001 2.0001];
y1L=f(xL) % DO NOT CHANGE CODE ON THESE TWO LINES
y1R=f(xR) % Leave the semicolons off to see the y-values and estimate the limits
% Part b
g=@(x) (x.^2-4*x)/abs(x-4);
xL=[3.999 3.9999 3.99999 3.999999];
xR=[4.0000001 4.000001 4.00001 4.0001];
y2L=g(xL) % DO NOT CHANGE CODE ON THESE TWO LINES
y2R=g(xR) % Leave the semicolons off to see the y-values and estimate the limits
3 Comments
Rik
on 25 Oct 2018
This code runs without error for me. What error are you getting? What release are you on?
Maryam AlKhoury
on 25 Oct 2018
Answers (2)
madhan ravi
on 25 Oct 2018
>> f=@(x) (x.^3-3*x.^2-4*x+12)/(x-2);
xL=[1.999 1.9999 1.99999 1.999999];
xR=[2.0000001 2.000001 2.00001 2.0001];
y1L=f(xL) % DO NOT CHANGE CODE ON THESE TWO LINES
y1R=f(xR) % Leave the semicolons off to see the y-values and estimate the limits
% Part b
g=@(x) (x.^2-4*x)/abs(x-4);
xL=[3.999 3.9999 3.99999 3.999999];
xR=[4.0000001 4.000001 4.00001 4.0001];
y2L=g(xL) % DO NOT CHANGE CODE ON THESE TWO LINES
y2R=g(xR)
y1L =
-4.0030
y1R =
-3.9997
y2L =
-3.9990
y2R =
4.0001
>>
4 Comments
madhan ravi
on 25 Oct 2018
where do you see error from the above?
madhan ravi
on 25 Oct 2018
Edited: madhan ravi
on 25 Oct 2018
are you sure you are using matlab? it doesn't look like one
Maryam AlKhoury
on 25 Oct 2018
madhan ravi
on 25 Oct 2018
I haven't used it but all I can say is the above code works with precise function passing with function handle I don't see why the error shows up then
Maryam AlKhoury
on 25 Oct 2018
0 votes
Categories
Find more on Startup and Shutdown 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!