フィルターのクリア

Matrices Dimensions Not Consistent when t=0:10

2 ビュー (過去 30 日間)
Laurel Castillo
Laurel Castillo 2018 年 12 月 3 日
編集済み: Walter Roberson 2018 年 12 月 11 日
Hi,
I don't understand why it says it's not consistent. It's a 4*4 matrix. Only the element depents on t grows, but not the whole matrix?
So if I want to grow it, I have to use for loop? Thanks!
t= 1:10;
psm_x_dsr = [1 0 0 0.25*(1-cos(pi*t));
0 1 0 0.25*(1-sin(pi*t));
0 0 1 0;
0 0 0 1];
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in main (line 15)
psm_x_dsr = [1 0 0 0.25*(1-cos(pi*t)); 0 1 0 0.25*(1-sin(pi*t)); 0 0 1 0; 0 0 0 1]';

採用された回答

KSSV
KSSV 2018 年 12 月 3 日
YOu need to store the result into a 3D matrix.
t= 1:10;
nt = length(t) ;
psm_x_dsr = zeros(4,4,nt) ;
for i = 1:nt
psm_x_dsr(:,:,i) = [1 0 0 0.25*(1-cos(pi*t(i)));
0 1 0 0.25*(1-sin(pi*t(i)));
0 0 1 0;
0 0 0 1];
end

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 12 月 3 日
編集済み: Walter Roberson 2018 年 12 月 11 日
t=1:10 does not tell MATLAB that t is a scalar variable whose values will be decided later but will be in the range 1 through 10.
t=1:10 tells MATLAB that you want to right now make t a vector with the values 1 2 3 4 5 6 7 8 9 10 stored in it.
with t being a vector pi*t is a vector and cos() of that is a vector and 1 minus cos is a vector and 1/4 times that is a vector .
Therefore [1 0 0 0.25etc] is a vector of length 13 not a vector of length 4.
If you want placeholder variables use the symbolic toolbox or create a function

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by