http://www.mathworks.com/matlabcentral/newsreader/view_thread/315632
MATLAB Central Newsreader  Help with Code
Feed for thread: Help with Code
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Mon, 02 Jan 2012 06:01:09 +0000
Help with Code
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315632#862598
Saptarshi Bhattacharjee
I have a problem where I am given a function f(x) where I need to plot the curve between f(x) and x. The problem I am facing is with dealing with the multiple outputs of f(x) for each x. Range of x is [0,4]. Can anyone help me with this??

Mon, 02 Jan 2012 07:12:07 +0000
Re: Help with Code
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315632#862604
Roger Stafford
"Saptarshi Bhattacharjee" wrote in message <jdrh75$md9$1@newscl01ah.mathworks.com>...<br>
> I have a problem where I am given a function f(x) where I need to plot the curve between f(x) and x. The problem I am facing is with dealing with the multiple outputs of f(x) for each x. Range of x is [0,4]. Can anyone help me with this??<br>
         <br>
Could you please be more explicit about the statement "I am given a function"? In what form is the function given to you that would enable it to be multivalued?<br>
<br>
As an example of what you might be facing, suppose you are given the implicit equation:<br>
<br>
(x2)^2 + y^2 = 4<br>
<br>
As we all know, this is the equation of a circle with center at (2,0) and radius 2, but if we try to express y as a function of x, we find that there are actually two functions:<br>
<br>
y = sqrt(x*(4x))<br>
<br>
and<br>
<br>
y = sqrt(x*(4x))<br>
<br>
You can either use both functions in creating a plot in two separate pieces, the upper half circle and the lower one, or else you can seek some parameter that will generate the entire curve. This latter parametric approach would look like this:<br>
<br>
a = linspace(0,2*pi); % Arc angles to points around the circle<br>
x = 2+2*cos(a); % x coordinates of those points<br>
y = 2*sin(a); % y coordinates of those points<br>
plot(x,y) % Plot y against x<br>
<br>
Roger Stafford