How to correct the code?
Mostrar comentarios más antiguos
Hello!
I wrote this code:
X=rand(5,3);
Y=zeros(5,3);
for k=1:5
for j=1:3
if X(k,j)<0.2
Y(k,j)=-1;
else
Y(k,j)=1;
end
end
end
I have to write the same code but without using any loop. How to do this?
1 comentario
Cedric
el 28 de Abr. de 2019
Google "MATLAB logical indexing" and understand it, and you'll have the tools for solving your problem.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Language Support en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!