The graph of the function , f(x)=a*x^4+b*x^3+c*x^2+d*x+e, passes through the points (-3, 6.8), (-1.5, 15.2), (0.5, 14.5), (2, -21.2), and (5, 10). Write a script that will prompt for the ordered pairs as inputs and solve five equations with the five unknown constants: a, b, c, d, and e. You need to set up a matrix equation and solve for the unknowns by first finding the inverse of a matrix. Solve the system: y = X * h, for h

댓글 수: 6

John D'Errico
John D'Errico 2015년 2월 3일
Ok. So it tells you exactly what to do. Whats the problem? Make an effort, as that is how you learn. This homework is for you after all, not us.
Try something. If you have a problem THEN ask a question. You will get a better reception then. And you will probably even get some help - THEN.
Nguyen
Nguyen 2015년 2월 3일
편집: John D'Errico 2015년 2월 3일
This is what I have so far,
%inputing the ordered pairs
pair1=input('Enter the first ordered pair as a vector [a,b]:');
pair2=input('Enter the second ordered pair as a vector [a,b]:');
pair3=input('Enter the third ordered pair as a vector [a,b]:');
pair4=input('Enter the fourth ordered pair as a vector [a,b]:');
pair5=input('Enter the fifth ordered pair as a vector [a,b]:');
My question is what do I plug in for the X matrix? And I am sorry that I do not know how to ask questions, I have been working on this lab since last week and the teacher has not been responding to me. Also I have never used MatLab so what you might think is easy is not really easy so people who have never touched this program before. The y in this case would be the y values in the coordinates, right? So what would the X be in this case?
Nguyen
Nguyen 2015년 2월 3일
I am sorry if I sound rude, but I am frustrated that I cannot understand what to do. Because the question looks easy, I just do not understand what I am supposed to plug in for the X matrix.
Nguyen
Nguyen 2015년 2월 3일
I know to solve for a,b,c,d, and e I have to use h=inv(x)*y
I fixed the code formatting. When you include code, select it, then click on the button that says "{} code". This will make your code readable for others.
Ok. so you have at least made some effort. Admittedly, it is rarely a good thing to have an interface with lots of input statements. And naming a list of variables as you have will get you in trouble one day. So, how about this as a simplification?
for ind = 1:5
xy(ind,:) = input('Enter an ordered pair as a vector [a,b]:');
end
This will create an array of size 5x2, where the first column is x, the second column y. You could split the columns apart, perhaps as
x = xy(:,1);
y = xy(:,2);
As for how to create the X matrix, you should look at the vander function. What would vander(x) do then? TRY IT!
If you cannot use vander (read, are not allowed) then ask again, but first, think about what vander produces. Is there a way to create that matrix yourself?
Nguyen
Nguyen 2015년 2월 3일
What is vander? I cannot find it in my book and my professor has not talked about it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Youssef  Khmou
Youssef Khmou 2015년 2월 3일
편집: Youssef Khmou 2015년 2월 3일

0 개 추천

Since this is homework, partial answer is given, You have to start with the following :
X=[(-3)^4 (3)^3 (3)^2 3 1;
(-1.5)^4 (-1.5)^3 (-1.5)^2 (-1.5) 1;
(0.5)^4 (0.5)^3 (0.5)^2 (0.5) 1;
(2)^4 (2)^3 (2)^2 2 1;
(5)^4 (5)^3 (5)^2 5 1];

댓글 수: 4

Nguyen
Nguyen 2015년 2월 3일
Why did my professor say to use "pair1=input('Enter the first ordered pair as a vector [a,b]:');" in the script? I am really confused by this.
Youssef  Khmou
Youssef Khmou 2015년 2월 3일
You can use any notation/variable you want, the most important part of the problem is the construction of X.
Nguyen
Nguyen 2015년 2월 3일
Okay, so I can just type this in to a script? And in the input line of the command box I can just type in the name if the script file and it would give me an answer?
Youssef  Khmou
Youssef Khmou 2015년 2월 3일
correct

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2015년 2월 3일

댓글:

2015년 2월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by