How to define a column vector whose elements are column vector?

3 ビュー (過去 30 日間)
Deepak Patankar
Deepak Patankar 2017 年 7 月 4 日
コメント済み: Guillaume 2017 年 7 月 4 日
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?

回答 (2 件)

Guillaume
Guillaume 2017 年 7 月 4 日
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 件のコメント
Deepak Patankar
Deepak Patankar 2017 年 7 月 4 日
Thanks Sir
Actually I am using ssest(data(as iddata),nx) to find the estimated parameters for my state space model.
x[t+Ts]=Ax[t] + Bu[t]
y[t] = C*x[t]
where u[t] is a nX3 matrix( n is number of sample) and y[t] is n*1 matrix.
Since u[t] is nX3 the output y[t] comes 1X3, but to get the best estimate y[t] must be 1X1 ( I tried taking y as [output,0,0] and few more combinations it was not giving good result). Thus to take y as 1X1 my u must be 3X1, that's why I asked the question which you answered earlier.But I am unable to use cell array in iddata. Can you suggest some solution for the actual problem ?
Guillaume
Guillaume 2017 年 7 月 4 日
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
David Goodmanson 2017 年 7 月 4 日
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 件のコメント
Deepak Patankar
Deepak Patankar 2017 年 7 月 4 日
編集済み: Deepak Patankar 2017 年 7 月 4 日
Thanks a lot sir for your answer
The question I asked was a small part of my actual problem which I have mentioned in Guillaume Sir's answer. Can you help me with the actual problem,I am trying it from quite a few days ?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by