Inserting a column vector as a column in a new matrix.
Afficher commentaires plus anciens
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 !!!
Réponse acceptée
Plus de réponses (3)
Matt J
le 17 Oct 2012
I suspect that this is what you really want:
vander(X).'
or
bsxfun(@power,X(:),[0,1,2]);
Swasti Khuntia
le 17 Oct 2012
0 votes
Matt J
le 17 Oct 2012
0 votes
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.
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!