フィルターのクリア

Delete specific rows in a multidimensional matrix

3 ビュー (過去 30 日間)
David Ponce
David Ponce 2018 年 10 月 23 日
編集済み: James Tursa 2018 年 10 月 24 日
Hello, I have a problem with deleting rows in my multidimensional matrix. The thing is that I have a matrix A 800X1X100 with angles and i have to delete the rows that meet the condition. Here is my code:
for k=1:1:100
if(or(Z(k,1,:)>=230,Z(k,1,:)<=330))
Z(k,1,:) = [];
end
end
here is the error: A null assignment can have only one non-colon index.
Thank you.
  1 件のコメント
David Ponce
David Ponce 2018 年 10 月 23 日
same error, but thanks for the answer.

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

回答 (1 件)

gonzalo Mier
gonzalo Mier 2018 年 10 月 24 日
The solution for your problem could be:
Z=rand(800,1,100)*400;
for(k=800:-1:1)
if(or(Z(k,1,:)>=230,Z(k,1,:)<=330))
Z((k-1)*100+(1:100)) = [];
Z = reshape(Z,[],1,100)
end
end
or use the squeeze function to make Z shape [800,100]
  1 件のコメント
David Ponce
David Ponce 2018 年 10 月 24 日
編集済み: David Ponce 2018 年 10 月 24 日
Thanks for the answer, but now I know the problem, the thing is that I have to reshape my multidimensional matrix as I go deleting the rows. I have this:
for m=1:1:size(Z,3)
for n=1:1:size(Z,1)
if(and(Z(n,1,m)>=230 , Z(n,1,m)<=330))
Z(n,1,m) = []; %here is the problem i have to reshape
end
end
end

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by