Incorrect use if/else

1 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by