Incorrect use if/else
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
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
.
1 Kommentar
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!