MATLAB Answers

Fina
0

Associate numeric values to object arrays

Asked by Fina
on 8 Jun 2019
Latest activity Commented on by Matt J
on 8 Jun 2019
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.

  0 Comments

Sign in to comment.

1 Answer

Answer by Matt J
on 8 Jun 2019
Edited by Matt J
on 8 Jun 2019
 Accepted Answer

I think this is what you mean?
objectList={A,B,C};
result=objectList(x+1)

  1 Comment

Matt J
on 8 Jun 2019
Fina's comment moved here:
Absolutely! Thank you, I'm new to Matlab!

Sign in to comment.