Info

この質問は閉じられています。 編集または回答するには再度開いてください。

??? Index exceeds matrix dimensions. Error in ==> Untitled at 267 if length(W{i})==0;

2 ビュー (過去 30 日間)
Tomas
Tomas 2013 年 12 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
{1x3 cell} {1x2 cell} {1x4 cell}
W{2}{1}={[1 2],[],[2 5 3]}
for i=1:size(W,2)
if length(W{i})==0;
W(cellfun('isempty',W))=[];%odstranenie prazdnych miest
else
%zmaze prazdne miesta v poli
W{i}(cellfun(@isempty,W{i})) = [];
end
end
W
I want to delete empty place in cell,2 events may occur once Z ={1x3 cell} [] {1x2 cell} [] {1x4 cell} or can be Z{1}= [1x3 double] [1x3 double] [1x3 double] [] []
Thanks.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 1 日
Try this
idx=cellfun(@isempty,W{2}{1});
W{2}{1}(idx)=[]
  5 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 1 日
I will give an example
W{1}{1}={[] 1:3 3:5 1:3 [] }
W{2}{1}={[] [] 1:3 1:3 }
idx=cellfun(@isempty,W{2}{1});W{2}{1}(idx)=[]
celldisp(W{2})
Tomas
Tomas 2013 年 12 月 1 日
i need when i have Z=[] {1x3 cell} {1x2 cell} i want to delete [] if length(Z(1))==0 error message
? Undefined function or method 'eq' for input arguments of type 'cell'.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by