How to vectorize the following code snippet ?
Mostra commenti meno recenti
M = randi([-10 10],10,10);
[m, n] = size(M);
out = zeros(m, n);
for x = 1:m
for y = 1:n
if M(x, y) > 0
out(x, y) = 1;
else if M(x, y) == 0
out(x, y) = 0;
else
out(x, y)=-1;
end
end
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Simulink Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!