Rational Function (MATLAB)

Status
Not open for further replies.

47box

Newbie level 5
Joined
Jan 8, 2014
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
101
Hi,

I´ve been trying to plot a rational function to see the graph of it.

f(x) = (2x4-x2+1) / x2-4


From a book I´m following a graph is showed below :

figure1


I created a script trying make a graph comes out.

Code:
clear
clc

x =(-100:0.01:100);
y = ((2.*(x.^4))-(x.^2)+1)./(x.^2)-4;
plot(x,y),hold on
axis([-4 4 -50 50])
grid on

I got a graph completely out of what we have in a image above from the book.



As we can see it pass the limits of -2 and 2.
How can I plot a graph and have the same as we have in the book (figure 1)?
I tried to see matlab materials and could not figure out how to do that.

Thanks in advance
 

Simply your denominator is wrong in coding.
Surely confirm parenthesis.

y = (2*x.^4-x.^2+1)./(x.^2-4);
 

Attachments

  • 171102-221307.png
    9.7 KB · Views: 180
Last edited:
Reactions: 47box

    47box

    Points: 2
    Helpful Answer Positive Rating
That is it. Thank you.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…