http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281
MATLAB Central Newsreader  character array from cell
Feed for thread: character array from cell
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Fri, 03 Jul 2009 20:45:03 +0000
character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662550
mohammad movassat
Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
<br>
ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
<br>
Thank you

Fri, 03 Jul 2009 20:55:02 +0000
Re: character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662552
Sadik
Hello Mohammad,<br>
<br>
If you pad the shorter character array with a sufficient number of blanks, you should be able to have that char array:<br>
<br>
G(1,:) = 'x+y+1 '; % I put three blanks at the end.<br>
G(2,:) = '3x5y+10';<br>
<br>
Best.<br>
<br>
"mohammad movassat" <movassat@gmail.com> wrote in message <h2lqkf$cqp$1@fred.mathworks.com>...<br>
> Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
> f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
> <br>
> ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
> <br>
> Thank you

Fri, 03 Jul 2009 21:22:01 +0000
Re: character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662556
mohammad movassat
"Sadik " <sadik.hava@gmail.com> wrote in message <h2lr76$jch$1@fred.mathworks.com>...<br>
> Hello Mohammad,<br>
> <br>
> If you pad the shorter character array with a sufficient number of blanks, you should be able to have that char array:<br>
> <br>
> G(1,:) = 'x+y+1 '; % I put three blanks at the end.<br>
> G(2,:) = '3x5y+10';<br>
> <br>
> Best.<br>
> <br>
> "mohammad movassat" <movassat@gmail.com> wrote in message <h2lqkf$cqp$1@fred.mathworks.com>...<br>
> > Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
> > f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
> > <br>
> > ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
> > <br>
> > Thank you<br>
<br>
Thank you, but the issue is that the equations I have are much larger than the equations I showed above. My equations are generated after a couple of algebric manupulations and are vey long. and they are stored in cells. So I need to convert them to char by a command and I can not simply write them as char. <br>
<br>
The equations I showed here were samples.

Fri, 03 Jul 2009 21:28:01 +0000
Re: character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662557
us
"mohammad movassat" <movassat@gmail.com> wrote in message <h2lqkf$cqp$1@fred.mathworks.com>...<br>
> Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
> f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
> <br>
> ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
> <br>
> Thank you<br>
<br>
you've been given solutions to your problem earlier...<br>
tell CSSM what ML version you have...<br>
<br>
us

Fri, 03 Jul 2009 21:34:01 +0000
Re: character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662559
mohammad movassat
"us " <us@neurol.unizh.ch> wrote in message <h2lt51$m7h$1@fred.mathworks.com>...<br>
> "mohammad movassat" <movassat@gmail.com> wrote in message <h2lqkf$cqp$1@fred.mathworks.com>...<br>
> > Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
> > f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
> > <br>
> > ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
> > <br>
> > Thank you<br>
> <br>
> you've been given solutions to your problem earlier...<br>
> tell CSSM what ML version you have...<br>
> <br>
> us<br>
<br>
The solutions did not work, so I'm asking for an alternative.<br>
the version I have is 7.0.4.<br>
<br>
mohammad

Fri, 03 Jul 2009 21:56:12 +0000
Re: character array from cell
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255281#662560
Sadik
Hi,<br>
<br>
You can loop through f like this.<br>
<br>
% First determine the longest sequence<br>
maxLength = 0;<br>
for k = 1:length(f)<br>
currentSeqLength = length(char(f{k}));<br>
if currentSeqLength > maxLength<br>
maxLength = currentSeqLength;<br>
end<br>
end<br>
<br>
% Now that we know the maximum length, we can now loop through f and get <br>
% the character array, say charF.<br>
<br>
for k = 1:length(f)<br>
currentSeq = char(f{k});<br>
charF(k,:) = [currentSeq repmat(' ',1,maxLengthlength(currentSeq))];<br>
end<br>
<br>
This should now work as you wanted.<br>
<br>
Best.<br>
<br>
<h2ltg9$ekf$1@fred.mathworks.com>...<br>
> "us " <us@neurol.unizh.ch> wrote in message <h2lt51$m7h$1@fred.mathworks.com>...<br>
<h2lqkf$cqp$1@fred.mathworks.com>...<br>
> > > Is there any way I can make a 2*1 character array from a 2*1 cell? I have a 2*1 cell:<br>
> > > f{1}=x+y+1 and f{2}=3x5y+10, (x and y are syms) I want to have a char G<2*1> with exactly the same elements. <br>
> > > <br>
> > > ps. the Matlab version I'm using is not very updated, so I'm looking for a way using basic commands in matlab not by specific toolboxes. any suggestions?<br>
> > > <br>
> > > Thank you<br>
> > <br>
> > you've been given solutions to your problem earlier...<br>
> > tell CSSM what ML version you have...<br>
> > <br>
> > us<br>
> <br>
> The solutions did not work, so I'm asking for an alternative.<br>
> the version I have is 7.0.4.<br>
> <br>
> mohammad