Thread Subject: How do I plot the second derivative of the lower half of a circle?

Subject: How do I plot the second derivative of the lower half of a circle?

From: Gerry Puckett

Date: 11 Nov, 2008 20:31:02

Message: 1 of 2

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!

Subject: How do I plot the second derivative of the lower half of a

From: Richard Brown

Date: 11 Nov, 2008 21:06:12

Message: 2 of 2

On Nov 12, 9:31=A0am, "Gerry Puckett" <egpuck...@ucdavis.edu> wrote:
> I am having difficulty understanding the syntax of defining a function th=
at - from the point of view of MATLAB - is really an array of values of tha=
t 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 =3D x_c;
> zmax =3D x_c + R;
>
> dz =3D 1/1000;
> z =3D zmin : dz : zmax;
>
> c =3D 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. =A0However, n=
ow I want to plot the second derivative of c(x) over the same interval and =
I've tried
>
> cpp =3D R*R / (sqrt( R^2 - (z - x_c).^2 )).^3;
>
> and a number of other expressions to no avail. =A0I apparently don't unde=
rstand the syntax ".^" and a number of other things about =A0MATLAB. =A0(I'=
m an old hand at FORTRAN and a variety of other computer languages and it s=
eems that I should be able to
> define a function
>
> function cpp(z) =3D R*R / (sqrt( R^2 - (z - x_c)^2 ))^3;
>
> and either implicitly or explicitly loop over the values of z and plot th=
e pair (z, cpp(z)). =A0However, I haven't found the appropriate part of MAT=
LAB help that shows me how to do this.
>
> I do have the symbolic toolbox, if that is the only way to accomplish wha=
t I want. =A0However, it seems logical that MATLAB must have a way to plot =
something as straight forward as , for example
>
> =A01/ sqrt( R^2 - (z - x_c)^2 ))^3;
>
> Thanks for your help!

Missing one more dot, should be dot-divide

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

cheers,

Richard
          ^^^

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com