Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: if not clear memory then the results are wrong
Replies: 4   Last Post: Jul 26, 2013 9:37 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mike

Posts: 336
Registered: 4/17/07
Re: if not clear memory then the results are wrong
Posted: Jul 26, 2013 1:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Friday, July 26, 2013 11:23:48 AM UTC+8, dpb wrote:
> ...
>

> > I have several row vectors.
>
> > I tranpose them with
>
> > A=A';B=B';C=C'; % I want to save them as column vectors
>
> > But A,B,C are still row one.
>
> > I run above procedures several times.
>
> >
>
> > After I 'clear all', rerun it and they are column vector.
>
> > Why?
>
>
>
> Something you're not showing...
>
>
>
> --


It is like:
m=0;
for i=1:nimg
% .... function returns a variable: var
if(isempty(var))
m=m+1;
img{m}=img0{i}; % img0 : cell array storing strings
continue;
end
end
img=img';

There is an warning about img: "variable appears changing on every loop." and it sugggests to preallocate the variable. I run two times and found first time is img is in column vector and the second time img is in row vector. I thought changing size variable is ok.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.