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

1 Ansicht (letzte 30 Tage)
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

Antworten (1)

Birdman
Birdman am 4 Apr. 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.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by