Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
cellfun isclass

Subject: cellfun isclass

From: Wendy

Date: 13 Mar, 2011 02:27:04

Message: 1 of 3

Hi all,

I have a cell array like the following

GeneList =
'GeneName' 'EntrezID'
'ACVR1' 90
'ACVR1B' 91

The class of CellList(2:3,2) is double. I would like to convert the class of these elements to char, so I tried

tf = cellfun('isclass',GeneList(:,2),'double')

tf = 0
      1
      1

But I am stuck at how to use the num2str function to the selected cell elements by tf parameter. Does anyone have any suggestion?

Thank you very much,
Wendy

Subject: cellfun isclass

From: per isakson

Date: 13 Mar, 2011 03:56:04

Message: 2 of 3

"Wendy " <wlq121@gmail.com> wrote in message <ilha1o$633$1@fred.mathworks.com>...
> Hi all,
>
> I have a cell array like the following
>
> GeneList =
> 'GeneName' 'EntrezID'
> 'ACVR1' 90
> 'ACVR1B' 91
>
> The class of CellList(2:3,2) is double. I would like to convert the class of these elements to char, so I tried
>
> tf = cellfun('isclass',GeneList(:,2),'double')
>
> tf = 0
> 1
> 1
>
> But I am stuck at how to use the num2str function to the selected cell elements by tf parameter. Does anyone have any suggestion?
>
> Thank you very much,
> Wendy

Try something like

cstr = cellfun( @( num ) num2str( num ), CellList, 'uni', false )

/ per

Subject: cellfun isclass

From: Bruno Luong

Date: 13 Mar, 2011 07:10:20

Message: 3 of 3

"Wendy " <wlq121@gmail.com> wrote in message <ilha1o$633$1@fred.mathworks.com>...
> Hi all,
>
> I have a cell array like the following
>
> GeneList =
> 'GeneName' 'EntrezID'
> 'ACVR1' 90
> 'ACVR1B' 91
>
> The class of CellList(2:3,2) is double. I would like to convert the class of these elements to char, so I tried
>
> tf = cellfun('isclass',GeneList(:,2),'double')
>
> tf = 0
> 1
> 1
>
> But I am stuck at how to use the num2str function to the selected cell elements by tf parameter. Does anyone have any suggestion?

 GeneList(tf,2)= cellstr(num2str(cat(1,GeneList{tf,2})))

Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us