필터 지우기
필터 지우기

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