Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Combination of variables   with a constraint
Date: Thu, 5 Apr 2012 17:43:26 +0000 (UTC)
Organization: Nokia Research Center
Lines: 39
Message-ID: <jlklju$9b4$1@newscl01ah.mathworks.com>
References: <jli2mb$5b6$1@newscl01ah.mathworks.com> <jli7ag$otd$1@newscl01ah.mathworks.com> <jliokd$sg2$1@newscl01ah.mathworks.com> <jlj9ur$q9m$1@newscl01ah.mathworks.com> <jlk885$dmv$1@newscl01ah.mathworks.com> <jlkjg5$oc$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1333647806 9572 172.30.248.38 (5 Apr 2012 17:43:26 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Apr 2012 17:43:26 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1019723
Xref: news.mathworks.com comp.soft-sys.matlab:763500

"Roger Stafford" wrote in message <jlkjg5$oc$1@newscl01ah.mathworks.com>...
> "Leyo Joseph" wrote in message <jlk885$dmv$1@newscl01ah.mathworks.com>...
> > Instaed of 0.25 on the right side, is it possible to make it a variable and plot it . Like for 0.2, 0.25, 0.3 and 0.35?
> - - - - - - - - - - - - -
>   For general k in the equation 
> 
>  sqrt((a.*sin(alpha)).^2+(1-a.*cos(alpha)).^2) = k
> 
> you can do this:
> 
>  n = 1000;
>  k = rand;
>  t = linspace(0,2*pi,n);
>  a = 1+k*cos(t);
>  calpha = (a.^2+1-k^2)./(2*a);  % This is cos(alpha)
>  salpha = k^2.*sin(t)./(2*a).*sqrt(4*a/k^2-sin(t).^2); % This is sin(alpha)
>  alpha = atan2(salpha,calpha);  % This gives alpha accurately
>  plot(a,alpha)
> 
> or for negative a's this:
> 
>  n = 1000;
>  k = rand;
>  t = linspace(0,2*pi,n);
>  a = -1+k*cos(t);
>  calpha = (a.^2+1-k^2)./(2*a);  % This is cos(alpha)
>  salpha = k^2.*sin(t)./(2*a).*sqrt(-4*a/k^2-sin(t).^2); % This is sin(alpha)
>  alpha = mod(atan2(salpha,calpha),2*pi);  % This gives alpha accurately
>  plot(a,alpha)
> 
>   Remember, there infinitely many versions of each of these contours that can be obtained by adding or subtracting multiples of 2*pi to alpha.
> 
>   Note: I have assumed here that k < 1.  This code has troubles with k > 1 but I haven't had time to see how it could be fixed in such cases.  Maybe you can work that out, Leyo.
> 
> Roger Stafford

Thanks ...
Yes my values are for k<1. 
I could figure out  the  derivation of " a " and "calpha". Still trying to figure out the drivation of "salpha" . I think I should be able to do if spend some more time. Thanks a lot for your help. I learned a lot from this exercise.