Path: news.mathworks.com!not-for-mail
From: "Tarik " <tarikak@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: for loop
Date: Mon, 13 May 2013 19:17:11 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 56
Message-ID: <kmre7n$mk0$1@newscl01ah.mathworks.com>
References: <kmqq4f$dpf$1@newscl01ah.mathworks.com>
Reply-To: "Tarik " <tarikak@gmail.com>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1368472631 23168 172.30.248.46 (13 May 2013 19:17:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 13 May 2013 19:17:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4304580
Xref: news.mathworks.com comp.soft-sys.matlab:795464

probably it is not understood properly...
my expectation is that this codes calculate n(9) for l=0 and =1(both) hence the result would be  
 ans =
> 
>      0     0     3
>      0     3     0
>      3     0     0
and
> ans =
> 
>      1     2     2
>      2     1     2
>      2     2     1

but here  I think for loop doesn't work properly
but where is the problem...
I hope someone can understand and help...
(sorry for this confusion)

"Tarik " <tarikak@gmail.com> wrote in message <kmqq4f$dpf$1@newscl01ah.mathworks.com>...
> hi...
> 
> it's really hard for me to explain what i want to calculate... but here is a part of my codes... when I write "n(9)"
> 
> ans =
> 
>      0     0     3
>      0     3     0
>      3     0     0
> 
> and if I cahange l as l=1:sqrt(ni) (it starts from 1)... now
> 
> ans =
> 
>      1     2     2
>      2     1     2
>      2     2     1
> 
> my problem is that both ans are in my expectation... I mean, for loop doesn't work well here... it looks that it stops after a solution... but why???
> 
>    for l=0:sqrt(ni)
>          x=l;                    
>          
>        y=real(fix(sqrt(ni-x^2)));       
>        if fix(y)==y           
>        z=real(fix(sqrt(ni-x^2-y^2)));       
>        if fix(z)==z           
>        if ni==x^2+y^2+z^2;          
>        n=[x,y,z];            
>        
>        result=unique(perms(n),'rows');       
>              return      
>               end
>               end
>               end
>       end