How to define a column vector whose elements are column vector?
Afficher commentaires plus anciens
I want to define a matrix like d=[ [1;2;3] ; [4;5;6] ; [7;8;9] ] such that d(1) gives a 3X1 matrix [1;2;3], but instead I am getting d matrix as 9X1 as d(1)=1. How can I represent my d matrix in the form given above?
Réponses (2)
Guillaume
le 4 Juil 2017
You have to use a cell array:
d = {[1;2;3]; [4;5;6]; [7;8;9]};
d{1} %to get the first vector
2 commentaires
Deepak Patankar
le 4 Juil 2017
Guillaume
le 4 Juil 2017
I know nothing about state space model and I don't really understand your problem.
In any case, since it's so vastly different to the question you've asked here, start a new question. You'll be a lot more likely to get an answer. Be a lot clearer in your new question.
David Goodmanson
le 4 Juil 2017
Hello Deepak,
If you want to create an actual matrix that you could access with a slightly different syntax, then
% commas concatenate horizontally, semicolons concatenate vertically
d=[ [1;2;3] , [4;5;6] , [7;8;9] ]
and then the columns would be addressed as d(:,1) = [1;2;3] etc.
1 commentaire
Deepak Patankar
le 4 Juil 2017
Modifié(e) : Deepak Patankar
le 4 Juil 2017
Catégories
En savoir plus sur Resizing and Reshaping 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!