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:
cell analysis

Subject: cell analysis

From: Wendy

Date: 9 Apr, 2010 11:41:06

Message: 1 of 2

Hi all,
I have a cell analysis question. I have two lists,

list1 = {'A', 'B', 'C'};
list2 =
'A' 'at1'
'B' 'at4'
'A' 'at6'
'C' 'at7'
'B' 'at5'
'A' 'at10'

I want an output as,
output =
A at1 at6 at 10
B at4 at5
C at7

I used
for i=1:length(list1);
    ix = strmatch(list1{i}, list2{:,1},'exact');
    output{i,1} = list1{i};
    output{i,2} = list2{ix,2};
end

This code works, but it takes too long. I wonder if I can use some other code to avoid the for loop, and make the code faster.

Thank you in advance
Wendy

Subject: cell analysis

From: Ashish Uthama

Date: 9 Apr, 2010 17:30:16

Message: 2 of 2

On Fri, 09 Apr 2010 08:41:06 -0300, Wendy <wlq121@gmail.com> wrote:

> Hi all,
> I have a cell analysis question. I have two lists,
>
> list1 = {'A', 'B', 'C'};
> list2 =
> 'A' 'at1'
> 'B' 'at4'
> 'A' 'at6'
> 'C' 'at7'
> 'B' 'at5'
> 'A' 'at10'
>
> I want an output as,
> output = A at1 at6 at 10
> B at4 at5
> C at7
>
> I used for i=1:length(list1);
> ix = strmatch(list1{i}, list2{:,1},'exact');
> output{i,1} = list1{i}; output{i,2} = list2{ix,2};
> end
>
> This code works, but it takes too long. I wonder if I can use some other
> code to avoid the for loop, and make the code faster. Thank you in
> advance
> Wendy

Maybe looping over list2 would be a bit faster(?)

Tags for this Thread

No tags are associated with 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