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:
guidance on ieteration

Subject: guidance on ieteration

From: Raymond

Date: 1 Oct, 2010 12:42:06

Message: 1 of 2

I need a function to manipulate a cell and concatanates the results into another cell. An example of what it's supposed to do:

function [out]=cellMix(input)

input= {{'abc', 'lks', 'oiw'}, {'tra', 'asdasd', 'wex'}, [2 3 1]} %input always 2 sub-cells %and one vector of doubles
output= {'atra2', 'lasdasd3', 'owex1'}

If the input were to contain capital letters:
{{'Dbc', 'lKs', 'Oiw'}, {'tRA', 'asDASd', 'WEX'}, [2 3 1]}
The output would be the same:
output= {'atra2', 'lasdasd3', 'owex1'}

So this function takes the first letter of the 1st sub-cell, takes the whole 2nd sub-cells, and finally the numbers in the vector. Then it concatanates them into the new output cell. I want to use a loop for this, but not sure which one. Can you provide some guidance? Thanks a lot!

Subject: guidance on ieteration

From: Sean

Date: 1 Oct, 2010 13:39:05

Message: 2 of 2

 I want to use a loop for this, but not sure which one. Can you provide some guidance? Thanks a lot!

Since you know how many iterations you need (number of elements in sub cells) then you would want a for-loop which has a prescribed beginning and ending.

for ii = 1:numel(cell{1})
   % extract stuff and concatenate (ii) %
end

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