Associate numeric values to object arrays

조회 수: 1 (최근 30일)
Fina
Fina 2019년 6월 8일
댓글: Matt J 2019년 6월 8일
I have a table with a list of numerical sequences. Here you can see how each object looks like:
>>x
x=
0 1 2 0 1 2
1 2 0 1 2 0
>> class(x)
ans =
'double'
>> A(1,1:3000)
ans =
Columns 1 through 16
0.3616 0.3090 0.2184 0.1905 0.2085 0.1760 0.1237 0.0691 0.0802 0.0427 -0.0064 -0.0402 -0.0670 -0.0386 0.0134 0.0204
Columns 17 through 30
0.0356 0.0732 0.1071 0.1062 0.0400 0.0064 -0.0789 -0.1627 -0.1519 -0.0841 -0.0818 -0.1089 -0.1376 -0.0800
I want to convert each number to an object previously created. For instance, A, B and C are class double (vectors of 1*3000). Therefore we want to associate an convert 0 to A, 1 to B and 2 to C. To sum up, convert the numerical sequence to a sequence of objects.

채택된 답변

Matt J
Matt J 2019년 6월 8일
편집: Matt J 2019년 6월 8일
I think this is what you mean?
objectList={A,B,C};
result=objectList(x+1)
  댓글 수: 1
Matt J
Matt J 2019년 6월 8일
Fina's comment moved here:
Absolutely! Thank you, I'm new to Matlab!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by