Incorrect use if/else

1 vue (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 11 Jan 2023
Commenté : Walter Roberson le 11 Jan 2023
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

Réponse acceptée

Star Strider
Star Strider le 11 Jan 2023
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 commentaire
Walter Roberson
Walter Roberson le 11 Jan 2023
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by