Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: reshape problem
Date: Sat, 2 Feb 2008 22:02:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <fo2p8p$naf$1@fred.mathworks.com>
References: <fo2n76$rk$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1201989721 23887 172.30.248.37 (2 Feb 2008 22:02:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 2 Feb 2008 22:02:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:448970


"Marcel " <JMarcel2@gmail.com> wrote in message <fo2n76$rk
$1@fred.mathworks.com>...
> Hi i have this script
> I want to reshape matrix A to matrix C with different number
>  of collums and rows
> 
>  A=[1 1 1  1 1;2 2 2 2 2;3 3 3 3 3 ;4 4 4 4 4 ;5 5 5 5 5];
>  C=[];
>  [m,n]=size(A);
>  p=m*n;
>  if p/8==0
>      d=p/8;
>      C=reshape(A,8,d)
>  else 
>      for i=1:7
>         while p/8==0 
>             
>             p=m*(n+i);
>             d=p/8;
>            C=reshape(A,d,8)
>          end
>          
>          end
>           
>      end
>     
>  end
> 
> but there is an error..
> 
> ??? Undefined function or variable 'C'.
> 
> Error in ==> C:\MATLAB6p5\work\TEST.m
> 
> where is the problem? 
> please let me know.
> Thanks
--------
  The quantity p/8 (= 25/8) is not zero, so in the 'else' part the 'while' loop 
never gets started in any of the seven trips through the 'for' loop.

Roger Stafford