# convert number in "*"

4 messages
Open this post in threaded view
|

## convert number in "*"

 hi,  f=[0 1 0 0 1 1] f =    0   1   0   0   1   1 i want to convert  0 in nan and 1 in * ans=[ nan * nan  nan * * ] it's possible to do this?     -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Open this post in threaded view
|

## Re: convert number in "*"

 turbofib wrote > hi, > > f(f == 0) = NaN > f = > >    0   1   0   0   1   1 > > i want to convert  0 in nan and 1 in * > > ans=[ nan * nan  nan * * ] > > it's possible to do this? Not literally as you start with a strictly numeric array (as you have square brackets around it) and want to convert it to an array containing strings ("*"). That is only possible with cell arrays. As an example the next sequence of commands: f(f == 0) = NaN f = num2cell (f) f = f(cellfun (@isfinite, f)) = "*" will do but undoubtedly there will be faster and more efficient ways. You *can* do f(f == 0) = NaN f(f == 1) = "*" but you'll end up  with f =    NaN    42   NaN   NaN    42    42 where 42 equals uint8 ("*") Philip -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html