필터 지우기
필터 지우기

Eliminate of empty matrix on cell structure.

조회 수: 2 (최근 30일)
Volkan Yangin
Volkan Yangin 2015년 11월 29일
편집: Volkan Yangin 2015년 11월 29일
Hi everbody.
I have 1*1724 cell structure and i want to find which cells are not empty matrix.
for l=1:1:1724
if buyuk_elemanlar{1,l}==[];
clear buyuk_elemanlar{1,l}
elseif
???
end
end
I don'nt know how type matlab code after the "elseif"?

답변 (2개)

Image Analyst
Image Analyst 2015년 11월 29일
Try it like this:
if isempty(buyuk_elemanlar{1,l})
% Cell is empty....
  댓글 수: 1
Volkan Yangin
Volkan Yangin 2015년 11월 29일
Thanks a lot Image Analyst, your solution is very helpful for me now. :-)

댓글을 달려면 로그인하십시오.


Jan
Jan 2015년 11월 29일
Use isempty instead of | == []|. clear is not useful to remove a single element. Do not remove elements of the cell inside the loop. Because then the loop index does not match the cell index anymore.
Different solutions:
m = false(1, 1724);
for k = 1:1724
if isempty(buyuk_elemanlar{1, k})
m(k) = true;
end
end
buyuk_elemanlar(m) = [];
Or:
m = false(1, 1724);
for k = 1:1724
m(k) = isempty(buyuk_elemanlar{1, k})
end
buyuk_elemanlar(m) = [];
Or:
m = cellfun('isempty', buyuk_elemanlar);
buyuk_elemanlar(m) = [];
The meaning of the "elseif ???" cannot be guessed. What should happen when the cell is not empty?
  댓글 수: 1
Volkan Yangin
Volkan Yangin 2015년 11월 29일
편집: Volkan Yangin 2015년 11월 29일
Thank you. Jan Simon. When i used elseif function, it is not useful for solve this problem, too. This only changes the for ex. 1x24cell to "l" Now i will use your solution with not using elseif and clear functions and i think, problem will be resolved by your codes. Thanks a lot again. :-)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by