Fun C I Ones Subplot Sci Lab

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

function [Y1]=fun1(x)

Y1 = (x+1)./(x^2-5*x+6);
endfunction

function [Y2]=fun2(x)
Y2 = x^3./(x-1)^3;
endfunction

x1=-5:0.1:5;
subplot(121);
title("a)f(x)= (x+1)/(x^2-5*x+6) ","fontsize",2);
plot2d(x1,fun1(x1),2);

x2=-5:0.1:5;
subplot(122);
title("b)f(x)= x^3/(x-1)^3; ","fontsize",2);
plot2d(x2,fun2(x2),5);

printf('Y=x^3./(x-1)^3\n')
printf('x | f(x)\n');
printf('------------\n');
for i=-5:5;
Z1 = fun1(i);
printf('%d | %d\n',i,Z1);
end
printf('Y2 = (x+1)./(x^2-5*x+6)\n')
printf('x | f(x)\n');
printf('------------\n');
for i=-5:5;
Z1 = fun2(i);
printf('%d | %d\n',i,Z1);
end

You might also like