How to use a for loop to iterate through a table?
Afficher commentaires plus anciens
Hi! I am very new to programming and I am trying to understand how to loop through a table. "indextable" is the table I am trying to loop through, and the values of indextable are the indices of cellnames. Hence I want 'i' to represent the values in indextable, rather than the indices. However, when I try the code below, rather than getting the appropriate values ex. (6, 9, 14), I get all the numbers from 6 to 14. How can I fix this? Thank you and I'm sorry if this is a simple question!
%%Make a polar plot
for column = 1:width(indextable) %columns in table
for i = indextable{1,column}:indextable{end,column};
cellname = cellnames{i}; %create looping variable
figure %create a new figure for each one
[firingRate,plottingangles]=Calculate_Firing_Rate(spiketimes(cellname),angleData); %FR function
polarplot(deg2rad(plottingangles),firingRate); %convert to radians
title(cellname);
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical 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!