help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applying a function to selected element type in a mixed-type cell ar


From: Juan Pablo Carbajal
Subject: Re: Applying a function to selected element type in a mixed-type cell array
Date: Mon, 21 May 2012 23:53:43 +0200

On Mon, May 21, 2012 at 11:43 PM, Philip Nienhuis <address@hidden> wrote:
> arr = {10, int32(15), 'Txt'; '', 25, true; NaN, 'String', single(100)}

Try

function x = f(y)
 if isnumeric(y)
    x=double(y);
 else
    x=y;
 end
endfunction

cellfun(@f,arr,'UniformOutput',false)

-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]