필터 지우기
필터 지우기

Incorrect use if/else

조회 수: 1 (최근 30일)
Alberto Acri
Alberto Acri 2023년 1월 11일
댓글: Walter Roberson 2023년 1월 11일
Hi. How can I make the following if/else work ?
cell = {[],[],[]};
cell1 = {rand(1452,2),[],[]};
A = cell{1,1};
B = cell1{1,1};
if A = []
B(:,2)=[];
else
....
end

채택된 답변

Star Strider
Star Strider 2023년 1월 11일
Perhaps this —
cell = {[],[],[]};
cell1 = {rand(1452,2),[],[]};
A = cell{1,1};
B = cell1{1,1};
if isempty(A)
B(:,2)=[];
else
% What do you want to do here?
end
B
B = 1452×1
0.4969 0.7029 0.9556 0.4312 0.7830 0.4565 0.6727 0.7772 0.8387 0.8329
.
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 1월 11일
Note that matlab uses == for comparisons.
Exception: if you use a comparison in a symbolic expression, especially a piecewise expression, then the visual representation when you display it might use = instead of == . The visual representation of symbolic expressions is not always valid input to matlab or to the internal symbolic engine either.

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

추가 답변 (0개)

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by