[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: convert number in "*"
From: |
PhilipNienhuis |
Subject: |
Re: convert number in "*" |
Date: |
Sat, 2 Feb 2019 05:30:03 -0600 (CST) |
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