- find how many values there are.
- repeat that code for each variable.
Loop through a matrix with multiple elements with the same values
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Based on this answer given by Cedriv Wannaz, I would like to ask how to generalize the answer. I mean that I know than in the column exist multiple values but I do not know how many they are, but I want to extract the entries as shown in the answer. How do I iterate through the values in order to succeed that?
0 commentaires
Réponses (1)
Stephen23
le 30 Sep 2015
Modifié(e) : Stephen23
le 30 Sep 2015
The basic steps will be to:
It seems that you are wanting each unique values in the first column of that matrix, in which case you can use unique to get a vector of the unique values:
V = unique(data(:,1));
Then loop over them using a for loop:
for k = numel(V):-1:1
V(k) % value of that loop iteration
... do whatever code with that value
out{k} = ... % save the results
end
Exactly how you save the results (or if they are saved at all) depends on you and what post-processing you want to perform. As you have not told us anything about the post-processing of this data after this step it is difficult to advise on the best way to store the output data.
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!