Path: news.mathworks.com!not-for-mail
From: "Gerry Puckett" <egpuckett@ucdavis.edu>
Newsgroups: comp.soft-sys.matlab
Subject: How do I plot the second derivative of the lower half of a circle?
Date: Tue, 11 Nov 2008 20:31:02 +0000 (UTC)
Organization: University of California Davis
Lines: 33
Message-ID: <gfcq26$p57$1@fred.mathworks.com>
Reply-To: "Gerry Puckett" <egpuckett@ucdavis.edu>
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 1226435462 25767 172.30.248.37 (11 Nov 2008 20:31:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 Nov 2008 20:31:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 142421
Xref: news.mathworks.com comp.soft-sys.matlab:500288


I am having difficulty understanding the syntax of defining a function that - from the point of view of MATLAB - is really an array of values of that function. 

So for example, 

% c(x) is the circle that passes through (x_l, y_l) and (x_r, y_r) 
% and has center (x_c, y_c) and radius R. 

zmin = x_c;
zmax = x_c + R;

dz = 1/1000;
z = zmin : dz : zmax;

c = y_c - sqrt( R^2 - (z - x_c).^2 );

plot(z, c, 'r');

produces the plot of the portion of the circle that I want.  However, now I want to plot the second derivative of c(x) over the same interval and I've tried

cpp = R*R / (sqrt( R^2 - (z - x_c).^2 )).^3;

and a number of other expressions to no avail.  I apparently don't understand the syntax ".^" and a number of other things about  MATLAB.  (I'm an old hand at FORTRAN and a variety of other computer languages and it seems that I should be able to 
define a function 

function cpp(z) = R*R / (sqrt( R^2 - (z - x_c)^2 ))^3;

and either implicitly or explicitly loop over the values of z and plot the pair (z, cpp(z)).  However, I haven't found the appropriate part of MATLAB help that shows me how to do this.

I do have the symbolic toolbox, if that is the only way to accomplish what I want.  However, it seems logical that MATLAB must have a way to plot something as straight forward as , for example

 1/ sqrt( R^2 - (z - x_c)^2 ))^3;

Thanks for your help!