- find how many values there are.
- repeat that code for each variable.
Loop through a matrix with multiple elements with the same values
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Stephen23
il 30 Set 2015
Modificato: Stephen23
il 30 Set 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 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!