How to give a dynamic variable name in for loop?

2 vues (au cours des 30 derniers jours)
Ararat Cetinkaya
Ararat Cetinkaya le 8 Mar 2020
Commenté : John D'Errico le 8 Mar 2020
Hi everybody,
I have a 4500x3 sized matrix. First two columns of the matrix contains the x and y value of the data set and third column contains the class labels as a numeric value like 7,3,1 sizes of the classes are not same and changing accourding to the user input. I want to sort each class from this main matrix to class1,class2, classn in a for loop.
  2 commentaires
dpb
dpb le 8 Mar 2020
"I want to sort each class from this main matrix to class1,class2, classn..."
That may be what you want to do, but it's almost certainly NOT the way to proceed.
Instead, read the data into an array and use the CLASSID variable as a grouping variable to process the data by group.
Showing a small subset of the file would help folks to see what it actually is...
John D'Errico
John D'Errico le 8 Mar 2020
It may be what you think you want to do.
Instead, do some reading there, and recognize it may not be a good idea.
Instead, learn to use arrays of the many types available in MATLAB. Perhaps a cell array if necessary.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by