How to create a specific vector c that has two variables x and y ?
2 次查看(过去 30 天)
显示 更早的评论
the problem here is this vector must be found from c = A\b. A and b are created from two variables x and y. (I posted the image of example xi,yi). x and y come from the normal parabola(ax^2 + bx +c) first, then they could be used in the matrix to form A and b. if my question is too confusing, just see the image...sorry, I am not good at explaining a problem :c Is there a way to solve it ? Thank you.
![](/matlabcentral/answers/uploaded_files/106546/QQ%E5%9B%BE%E7%89%8720180227191056.jpg)
3 个评论
回答(1 个)
Roger Stafford
2018-2-28
编辑:Stephen23
2018-2-28
Assume your xi's and yi's are given by a couple of column vectors, x and y of the same length.
n = length(x);
A = [x.^(n-1:-1:0)];
c = A\y;
2 个评论
Roger Stafford
2018-2-28
If you have an older version of matlab, use
A = bsxfun(@power,x,((n-1):-1:0));
where again I assume x is a column vector.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!