Inserting a column vector as a column in a new matrix.
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I have a column vector (say X). And I want to make that vector as a column in my new matrix, i.e., the first column is only 1s, second column is X and third column is X^2.
Any idea as how to do it?
Thanks !!!
0 件のコメント
採用された回答
その他の回答 (3 件)
Matt J
2012 年 10 月 17 日
I suspect that this is what you really want:
vander(X).'
or
bsxfun(@power,X(:),[0,1,2]);
0 件のコメント
Matt J
2012 年 10 月 17 日
I'm also going to hazard a guess that the matrix you're trying to create is meant so that you can fit a quadratic polynomial.
If so, you should probably be using POLYFIT instead, which is more stable.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!