Luke Mue
Luke Mue

Reputation: 9

Matlab assign Value to String

I got an array with values which are either 1 or 2 like:

val = [1,2,2,1,...]

Now I want to generate a new array in which every value of val is replaced with a String like:

str = {'accept', 'not accept','not accept', 'accept',...}

Can someone help me to get it done with Matlab?

Thanks in advance!

Upvotes: 0

Views: 52

Answers (1)

OmG
OmG

Reputation: 18838

Suppose you have a cell like options = {'accept', 'not accept'}. One solution can be:

str =options(val)

So, if val = [1 2 2 1 ...] the result would be:

str = {'accept', 'not accept','not accept', 'accept',...}

Upvotes: 1

Related Questions