Is it another command using to compare between vector and cell?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mira le
am 30 Okt. 2019
Kommentiert: Mira le
am 30 Okt. 2019
I have this code bellow: when U = [] and has value after , S also the same initila by S = {},
I use IsContainedIn to compare between each value fo U and S, but it doesn't work, an error appear : "Input A of class double and input B of class cell must be cell arrays of character vectors, unless one is a character vector."
Could you please help me I 'm stuck in this step
for i=1:numel(U)
if ~IsContainedIn(U(i),S{p})
w1 = [w1 U(i)];
end
end
Thanks
6 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 30 Okt. 2019
Then, to obtain the elements of U that doesn't exist in S, you can do:
U = [1,2,3];
S = {1,2};
w = U(~ismember(U,cell2mat(S)))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!