How to vectorize this for loop
Afficher commentaires plus anciens
Hello.Here's my codes from a program.I want to improve its efficiency,so I try to vectorize for loop.But I'm just a beginner in coding.I can't figure it out.Hope anyone who mastering in Matlab can help me to solve this.Thanks.
K = 10;
N = 10;
M = 10;
X(1:10,1:10) = 1;
seed_num = 123;
rng(seed_num);
B = abs(randi([1,100],M,N))
a = [];
m = [];
for l = 1:K
for j = 1:N
for k = 1:M
num = X(l,k)*B(k,j);
a = [a,num];
end
m = [m,max(a)];
a = [];
end
end
S = sum(m);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!