Filter löschen
Filter löschen

Incorrect use if/else

1 Ansicht (letzte 30 Tage)
Alberto Acri
Alberto Acri am 11 Jan. 2023
Kommentiert: Walter Roberson am 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

Akzeptierte Antwort

Star Strider
Star Strider am 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 Kommentar
Walter Roberson
Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by