From: TideMan on
On May 19, 2:47 pm, "Shafi " <ait...(a)yahoo.com> wrote:
> Thanks for your suggestion. Actually,  I have used eval function to generate the name of the all matrix (m1,m2... m500). Please see below part  of the code.
>
> %%%%%%%%%%%%%%%%%%%%%
> for i=1:500;
>
>    [mF] = mn + std.*randn(40,1); % creating  a matrix of Multiplying facto(mF)
>    eval(['mmF' num2str(i) ' = mF'])% Storing each mF to differnt Matric name
>
> end
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> However, I did not get your second point. Could you please explain bit more?
>
> Thanks and regards
> Shafi
>
> ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <bc6e419e-d1d1-46e2-afaf-ec10e6cb0...(a)c11g2000vbe.googlegroups.com>...
> > If all the column vectors have different names (e.g. m1, m2, m3,
> > m4, ... up to m500), you're kind of stuck doing it manually, unless
> > you want to try creating commands with sprintf and using eval to
> > string them together.  Is there any pattern to the variable names,
> > like I showed above, such that you could use sprintf() to create the
> > variable names, and use sprintf again to create the commands for use
> > by eval()?

Well, that shows the folly of using the evil function eval in the
first place.
You have gotten yourself into this pickle. Now you will have to get
yourself out of it.
I have no sympathy for you whatsoever.

But here is what you should have done:
mF=zeros(40,500); % Preallocate
for ic=1:500
mF(:,ic) = mn + std.*randn(40,1); % creating a matrix of
Multiplying facto(mF)
end

Now you have the matrix that you were asking for without using eval at
all.

From: Shafi on
Thanks a lot. Your is solution simply excellent. Actually, I have started learning MATLAB just from middle of February 2010 and am not familiar with all the features.

Anyway, thanks a lot.

Shafi

TideMan <mulgor(a)gmail.com> wrote in message <abc69f7c-c383-4023-8c85-95bfbb791553(a)j36g2000prj.googlegroups.com>...
> On May 19, 2:47 pm, "Shafi " <ait...(a)yahoo.com> wrote:
> > Thanks for your suggestion. Actually,  I have used eval function to generate the name of the all matrix (m1,m2... m500). Please see below part  of the code.
> >
> > %%%%%%%%%%%%%%%%%%%%%
> > for i=1:500;
> >
> >    [mF] = mn + std.*randn(40,1); % creating  a matrix of Multiplying facto(mF)
> >    eval(['mmF' num2str(i) ' = mF'])% Storing each mF to differnt Matric name
> >
> > end
> > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> >
> > However, I did not get your second point. Could you please explain bit more?
> >
> > Thanks and regards
> > Shafi
> >
> > ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <bc6e419e-d1d1-46e2-afaf-ec10e6cb0...(a)c11g2000vbe.googlegroups.com>...
> > > If all the column vectors have different names (e.g. m1, m2, m3,
> > > m4, ... up to m500), you're kind of stuck doing it manually, unless
> > > you want to try creating commands with sprintf and using eval to
> > > string them together.  Is there any pattern to the variable names,
> > > like I showed above, such that you could use sprintf() to create the
> > > variable names, and use sprintf again to create the commands for use
> > > by eval()?
>
> Well, that shows the folly of using the evil function eval in the
> first place.
> You have gotten yourself into this pickle. Now you will have to get
> yourself out of it.
> I have no sympathy for you whatsoever.
>
> But here is what you should have done:
> mF=zeros(40,500); % Preallocate
> for ic=1:500
> mF(:,ic) = mn + std.*randn(40,1); % creating a matrix of
> Multiplying facto(mF)
> end
>
> Now you have the matrix that you were asking for without using eval at
> all.
From: TideMan on
On May 19, 4:26 pm, "Shafi " <ait...(a)yahoo.com> wrote:
> Thanks a lot. Your is solution simply excellent. Actually, I have started learning MATLAB just from middle of February 2010 and  am not familiar with all the features.
>
> Anyway, thanks a lot.
>
> Shafi
>
> TideMan <mul...(a)gmail.com> wrote in message <abc69f7c-c383-4023-8c85-95bfbb791...(a)j36g2000prj.googlegroups.com>...
> > On May 19, 2:47 pm, "Shafi " <ait...(a)yahoo.com> wrote:
> > > Thanks for your suggestion. Actually,  I have used eval function to generate the name of the all matrix (m1,m2... m500). Please see below part  of the code.
>
> > > %%%%%%%%%%%%%%%%%%%%%
> > > for i=1:500;
>
> > >    [mF] = mn + std.*randn(40,1); % creating  a matrix of Multiplying facto(mF)
> > >    eval(['mmF' num2str(i) ' = mF'])% Storing each mF to differnt Matric name
>
> > > end
> > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> > > However, I did not get your second point. Could you please explain bit more?
>
> > > Thanks and regards
> > > Shafi
>
> > > ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <bc6e419e-d1d1-46e2-afaf-ec10e6cb0...(a)c11g2000vbe.googlegroups.com>...
> > > > If all the column vectors have different names (e.g. m1, m2, m3,
> > > > m4, ... up to m500), you're kind of stuck doing it manually, unless
> > > > you want to try creating commands with sprintf and using eval to
> > > > string them together.  Is there any pattern to the variable names,
> > > > like I showed above, such that you could use sprintf() to create the
> > > > variable names, and use sprintf again to create the commands for use
> > > > by eval()?
>
> > Well, that shows the folly of using the evil function eval in the
> > first place.
> > You have gotten yourself into this pickle.  Now you will have to get
> > yourself out of it.
> > I have no sympathy for you whatsoever.
>
> > But here is what you should have done:
> > mF=zeros(40,500);  % Preallocate
> > for ic=1:500
> >   mF(:,ic) = mn + std.*randn(40,1); % creating  a matrix of
> > Multiplying facto(mF)
> > end
>
> > Now you have the matrix that you were asking for without using eval at
> > all.

Two other pieces of gratuitous advice:

1. Do not top post. Top posting makes a thread hard to follow. Put
your replies UNDERNEATH.

2. Do not use i or j for indexes. By default they are sqrt(-1),
which can be very useful, unless you have redefined them as an index,
then they no longer mean what you think they mean. That can cause a
lot of grief until you realise what has happened. You can avoid this
simply by using k, m, or n or add a letter like ix or iy.