MATLAB CODE PLEASE! Plot the function in the domain f(x) = (x^2 - 6x + 7) / (x^3
ID: 3197040 • Letter: M
Question
MATLAB CODE PLEASE!
Plot the function in the domain f(x) = (x^2 - 6x + 7) / (x^3 - 8). In the domain 0 <= x <= 4. Notice that the
function has a vertical asymptote at x = 2 . Plot the function by creating
two vectors for the domain of x. The first vector (name it x1) includes ele-
ments from 0 to 1.9, and the second vector (name it x2) includes elements
from 2.1 to 4. For each x vector create a y vector (name them y1 and y2) with
the corresponding values of y according to the function. To plot the func-
tion make two curves in the same plot (y1 vs. x1, and y2 vs. x2).
Explanation / Answer
f = @(x) (x .^2 - 6x + 7) . / (x .^3 - 8) ; //%/anonymous Function For 'f'
x = 0 : dx :4;
y = f(x);
figure(1)
plot( x,y)
grid
f = @(x1) (x1 .^2 - 6x1 + 7) . / (x1 .^3 - 8) ;
x1 = 0 :dx : 1.9 ;
y1 = f(x1);
plot(x1,y1)
grid
f = @(x2) (x2 .^2 - 6x2 + 7) . / (x2 .^3 - 8) ;
x2 = 2.1 : dx: 4 ;
y2 = f(x2);
plot(x2,y2)
grid
plot (x1,x2,y1.y2)
axis ([0 4])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.