Need to get dimensions to match and to return a 0 x 0 matrix for empty row.
이전 댓글 표시
This code give me a 1 x 0 array for any row that is empty. I need it to return a 0 x 0 empty matrix for any row that is empty. It is presently giving me an error and proclaiming that the dimensions of the object in the "if" statement don't match.
function S = logipack( V)
m = size(V, 1);
S = cell(m, 1);
for r = 1:m
S{r} = find(V(r, :));
if find(V(r,:))==[]
S{r}= [];
end
end
end
댓글 수: 5
the cyclist
2016년 12월 16일
What data type is V?
Geoff Hayes
2016년 12월 16일
편집: Geoff Hayes
2016년 12월 16일
DJ - this is the third time that you have posted a question that deals with the same problem of writing the logipack function. Why not continue at https://www.mathworks.com/matlabcentral/answers/317178-what-is-wrong-with-this or https://www.mathworks.com/matlabcentral/answers/317062-told-to-ask-a-new-question-why-won-t-this-work?
Also, consider using the MATLAB debugger to step through the code to understand what is happening. See https://www.mathworks.com/help/matlab/debugging-code.html for details.
Jan
2016년 12월 18일
@DJ V: You discus the problem "find(V(r,:))==[]" here, although the answer I've given at https://www.mathworks.com/matlabcentral/answers/317178-what-is-wrong-with-this#answer_247497 contains the correct isempty() already. By this way, you do not catch attraction, but discourage readers to care about your questions.
채택된 답변
추가 답변 (1개)
the cyclist
2016년 12월 16일
0 개 추천
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!