how can i truncte a matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
how can i truncate matrix with 51*500 to 51*71?
0 件のコメント
回答 (2 件)
Dave B
2021 年 11 月 14 日
編集済み: Dave B
2021 年 11 月 14 日
Are you asking how to take a 51 x 500 matrix and remove all but the first 71 columns?
x = rand(51,500);
x = x(:,1:71); % read this as x("all rows", "columns 1 to 71")
2 件のコメント
Dave B
2021 年 11 月 14 日
the code above runs just fine:
x = rand(51,500);
x = x(:,1:71);
size(x)
The error indicates that the matrix has just one column:
a = rand(51,1); % this only has one column, how can I take the first 71 columns?
a(:,1:71)
Tina
2021 年 11 月 14 日
if you have 51*500 try doing
a=zeros(51,500)
b=a(:,1:71)
and if you have 500*51
a=zeros(500,51)
b=a(1:71,:)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!