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

2 次查看(过去 30 天)
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

回答(1 个)

Birdman
Birdman 2018-4-4
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.

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by