Assignment has more non-singleton rhs dimensions than non-singleton subscripts
조회 수: 8 (최근 30일)
이전 댓글 표시
Why do i keep on getting this error code? The code executes well and the matrix gets populated with the right elements. It does what it supposed to but at the end spits out the error code.
filename = 'testGUI';
[num txt raw] = xlsread(filename,2);
%
clc
sz = size(txt)
row = sz(1);
column = sz(2);
for i = 1 : row
for j = 1 : column
idx(i,j) = find(not(cellfun('isempty', txt(i,j))))
end
end

댓글 수: 0
채택된 답변
추가 답변 (1개)
Walter Roberson
2018년 7월 7일
편집: Walter Roberson
2018년 7월 7일
You are passing individual txt(i,j) into cellfun('isempty') . Any one entry is either empty or not empty, so 1 (true, it is empty) or 0 (false, it is not empty) will be returned for any one call. You are then applying not() to that scalar 1 (is empty) or scalar 0 (is not empty), getting back 0 (is not empty is false because it is empty) or 1 (is not empty is true). You then apply find() to that scalar 0 or 1 value. In the case of the scalar 0 (was empty) the find will fail and the empty vector will be returned. In the case of the scalar 1 (was not empty) the find will work and the scalar 1 will be returned. So in one case it will return empty and the other case it will return 1. But your code expects that it will always return a scalar.
if what you want to create a logical array showing whether the entries in txt are empty (0) or not (1) then you would just use
idx = not( cellfun('isempty', txt) );
with no looping.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!