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:
String Manipulation

Subject: String Manipulation

From: Alan Leung

Date: 30 Jul, 2007 14:36:58

Message: 1 of 2

Hi,

1. I have an cell element called type_name:
type_name = 'A Math Example';

I would like to use type_name as the name of the worksheet
xlswrite('C:\A.xls',A,type_name,'A1:B2')

This statement does not work. How should I modify it?

2. This is a part of my code:
ID1 = {'A';'B';'C';};
for i = 1:1:3
  for j = 1:1:3
     for k = 1:1:3
       ...
     end
  end
end

Now, I would like to make a matrix so that it look something like:
Output = {'AAA';'AAB';'AAC';'ABA';...}

How should I do it?

Thanks,

Alan

Subject: String Manipulation

From: us

Date: 30 Jul, 2007 15:14:56

Message: 2 of 2

Alan Leung:
<SNIP combinatorial evergreen...

one of the many solutions

% some data
     tok='A':'C';
% the (versatile) engine
     n=numel(tok);
     x=cell(n,1);
     [x{1:n}]=ndgrid(tok);
     p=reshape(cat(n+1,x{:}),[],n);
     p=p(:,end:-1:1);
% the result
     tok
     p

us

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