Can someone help me? i think there's something wrong with my code..

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 commentaires

Today I formatted your code, next time, use the {}Code button. See here for a GIF showing how to do it.
This code runs without error for me. What error are you getting? What release are you on?
i cant leave space between them... when i click enter nothing happens. (this is an assignment placed by my teacher and i have to complete it)

Connectez-vous pour commenter.

Réponses (2)

>> 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 commentaires

where do you see error from the above?
madhan ravi
madhan ravi le 25 Oct 2018
Modifié(e) : madhan ravi le 25 Oct 2018
are you sure you are using matlab? it doesn't look like one
yes it's MatLab Grader
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by