Effacer les filtres
Effacer les filtres

Storing Outputs from a Nested Loop with a step

1 vue (au cours des 30 derniers jours)
Akila Udage
Akila Udage le 6 Avr 2020
Commenté : Akila Udage le 8 Avr 2020
data = xlsread ('file.xlsx' ,'sheet');
k=15;
for i = 1:16:128
for j= 1:16:128
submat = data(i:i+k,j:j+k);
Uniform(i,j) = (max(max(submat)))/(min(min(submat)))
end
In given code i want to store values i am getting for Uniform vector to 8 by 8 matrix. Problem here is since this has a step of 16 normal methods did not work.
Thnak you

Réponse acceptée

Ameer Hamza
Ameer Hamza le 6 Avr 2020
Method 1:
data = xlsread ('file.xlsx' ,'sheet');
k=15;
for i = 1:16:128
for j= 1:16:128
submat = data(i:i+k,j:j+k);
Uniform((i-1)/16+1,(j-1)/16+1) = (max(max(submat)))/(min(min(submat)))
end
Method 2:
data = xlsread ('file.xlsx' ,'sheet');
k=15;
count_i = 1;
for i = 1:16:128
count_j = 1;
for j= 1:16:128
submat = data(i:i+k,j:j+k);
Uniform(count_i,count_j) = (max(max(submat)))/(min(min(submat)))
count_j = count_j + 1;
end
count_i = count_i + 1;
  1 commentaire
Akila Udage
Akila Udage le 8 Avr 2020
Thank you very much
i used the second method and it worked. but you have to make sure count_j = 0 before restarting the loop

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by