On May 13, 12:16=A0am, Bob <rbe...@mathworks.com> wrote:
> Does this help?
>
> for k=3D1:nb
> =A0 =A0fprintf('%d =A0 =A0%s\n',k,Names{k})
> end
>
> Cheers
> Bob
Yes it works but I want it in vector form i.e. something as follows:
fprintf('%d %s\n',[1:nb],Names{[1:nb]})
and the above doesn't work. Any guess how I can put it in vector form.
n o s p a m p l e a s e <nospam.please@alum.com> wrote in
message
<c796a606-58d8-4874-b4cc-d5c6d8602495@c65g2000hsa.googlegroups.com>...
> On May 13, 12:16=A0am, Bob <rbe...@mathworks.com> wrote:
> > Does this help?
> >
> > for k=3D1:nb
> > =A0 =A0fprintf('%d =A0 =A0%s\n',k,Names{k})
> > end
> >
> > Cheers
> > Bob
>
> Yes it works but I want it in vector form i.e. something
as follows:
>
> fprintf('%d %s\n',[1:nb],Names{[1:nb]})
>
> and the above doesn't work. Any guess how I can put it in
vector form.
>
> Thanx/NSP
An example of comma-separated list expansion:
x = 1:3 ;
t = {'AA','B','CCC'} ;
% one big cell array
M = [num2cell(x) ; t]
% expansion
fprintf('\n%d\t %s',M{:})
Note that the order of M is important, before you apply
comma-separated list expansion. You might have to transpose
M before.
n o s p a m p l e a s e <nospam.please@alum.com> wrote in
message
<c796a606-58d8-4874-b4cc-d5c6d8602495@c65g2000hsa.googlegroups.com>...
> On May 13, 12:16=A0am, Bob <rbe...@mathworks.com> wrote:
> > Does this help?
> >
> > for k=3D1:nb
> > =A0 =A0fprintf('%d =A0 =A0%s\n',k,Names{k})
> > end
> >
> > Cheers
> > Bob
>
> Yes it works but I want it in vector form i.e. something
as follows:
>
> fprintf('%d %s\n',[1:nb],Names{[1:nb]})
>
> and the above doesn't work. Any guess how I can put it in
vector form.
>
> Thanx/NSP
An example of comma-separated list expansion:
x = 1:3 ;
t = {'AA','B','CCC'} ;
% one big cell array
M = [num2cell(x) ; t]
% expansion
fprintf('\n%d\t %s',M{:})
Note that the order of M is important, before you apply
comma-separated list expansion. You might have to transpose
M before.
n o s p a m p l e a s e <nospam.please@alum.com> wrote in
message <c796a606-58d8-4874-b4cc-
d5c6d8602495@c65g2000hsa.googlegroups.com>...
> On May 13, 12:16=A0am, Bob <rbe...@mathworks.com> wrote:
> > Does this help?
> >
> > for k=3D1:nb
> > =A0 =A0fprintf('%d =A0 =A0%s\n',k,Names{k})
> > end
> >
> > Cheers
> > Bob
>
> Yes it works but I want it in vector form i.e. something
as follows:
>
> fprintf('%d %s\n',[1:nb],Names{[1:nb]})
>
> and the above doesn't work. Any guess how I can put it
in vector form.
>
> Thanx/NSP
There is one more crude way.
Try this if it works :
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.