Answer to Question #211814 in MatLAB for Abu Huraira

Question #211814

The graph of a function 

𝑓(𝑥) = 𝑝𝑥

4 + 𝑞𝑥

3 + 𝑟𝑥

2 + 𝑠𝑥 + 𝑡

passes through the points ( 2.5, 62 ) , ( 1.5, 7.2 ) , ( 0.5, 8.3) , ( -1, -3.7 ) and ( -3, -45.7) . Write 

a program that determine the values of constants 𝑝, 𝑞, 𝑟, 𝑠,𝑡.


1
Expert's answer
2021-06-29T05:52:55-0400

The curve equation is taken as:

"f(x) = px^4 + qx^3 + rx^2 + sx + t"


Matlab Solution:


close all,
clear all,
clc,


x = [2.5, 1.5, 0.5, -1  , -3];
y = [6.2, 7.2, 8.3, -3.7, -45.7];
Order = 4;


scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
plot(x,y,'o');
n=4;                  %try with different n values
p=polyfit(x,y,n);             
f = polyval(p,x);
hold on,
plot(x,y,'o',x,f,'-');
xlabel('--- x --->');
ylabel('--- y --->');
title('X-Y Plot','FontSize',20);
grid on,
for r =1:length(x)
    str = strcat('(',num2str(x(r)),32,num2str(y(r)),')');
    text(x(r),y(r)-1,str);
end
disp(['p = ',num2str(f(1))]);
disp(['q = ',num2str(f(2))]);
disp(['r = ',num2str(f(3))]);
disp(['s = ',num2str(f(4))]);

disp(['t = ',num2str(f(5))]);


Matlab Output:

p = 6.2

q = 7.2

r = 8.3

s = -3.7

t = -45.7

>> 






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS