Inserting a column vector as a column in a new matrix.
조회 수: 2 (최근 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에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!