Effacer les filtres
Effacer les filtres

How do i get to store all the duplicate variables having different values in an array in matlab?

2 vues (au cours des 30 derniers jours)
For example i have 5 variables with the same name 'a' having different values in a a table. when i iterate through all the rows in the table ,i should be able to print all the duplicate variables along with their values and store them in an array
I am new to matlab.Can anyone give me a method to proceed with this.Anyhelp will be appreciated

Réponses (1)

Birdman
Birdman le 4 Avr 2018
Something like this?
Name={'a','a','a','b','b','c','a','a'}.'
Value=randi([1 7],size(Name,1),1)
Tab=table(Name,Value)
A=Tab.Value(strcmp(Tab.Name,'a'))
You generate 8 values for Value array randomly, then you gather them in a table. After that, you check which rows contains name a and by the power of logical indexing, you extract the values in those rows and store them in a new array.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by