how do I translate this intruction in matlab?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mira le
el 27 de Nov. de 2019
Comentada: Mira le
el 27 de Nov. de 2019
C={}
C <- C U {S}
W <- W \ {S}
0 comentarios
Respuesta aceptada
JESUS DAVID ARIZA ROYETH
el 27 de Nov. de 2019
Editada: JESUS DAVID ARIZA ROYETH
el 27 de Nov. de 2019
solution:
S=3;%any value of S
W=[1 2 3 4 8]; %aný value of W
C=[];%C={}
C(end+1)=S%C <- C U {S}
W=setdiff(W,S)%W <- W \ {S}
EDIT:
with cells you can do it like that, but if you are going to work with numbers I recommend working with matrices:
S={3};%any value of S
W={1 2 3 4 8}; %aný value of W
C={};%C={}
C(end+1)=S%C <- C U {S}
for k=1:numel(S)
W(cellfun(@(x,y) isequal(x,S{k}),W))=[]%W <- W \ {S}
end
3 comentarios
JESUS DAVID ARIZA ROYETH
el 27 de Nov. de 2019
here:
S={3};%any value of S
W={1 2 3 4 8}; %aný value of W
C={};%C={}
C(end+1)=S%C <- C U {S}
for k=1:numel(S)
W(cellfun(@(x,y) isequal(x,S{k}),W))=[]%W <- W \ {S}
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!