Help with matlab homework
古いコメントを表示
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
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
2015 年 2 月 3 日
編集済み: John D'Errico
2015 年 2 月 3 日
Nguyen
2015 年 2 月 3 日
Nguyen
2015 年 2 月 3 日
John D'Errico
2015 年 2 月 3 日
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
2015 年 2 月 3 日
回答 (1 件)
Youssef Khmou
2015 年 2 月 3 日
編集済み: Youssef Khmou
2015 年 2 月 3 日
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
2015 年 2 月 3 日
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
2015 年 2 月 3 日
Youssef Khmou
2015 年 2 月 3 日
correct
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!