フィルターのクリア

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

2 ビュー (過去 30 日間)
Giri
Giri 2018 年 4 月 4 日
コメント済み: Birdman 2018 年 4 月 9 日
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.
  2 件のコメント
Giri
Giri 2018 年 4 月 9 日
Thank you very much for the response @Birdman
Birdman
Birdman 2018 年 4 月 9 日
You are welcome. You can accept the answer if it helped.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by