0

I have a 3D curve in MATLAB, now I want to draw the derivative of that curve in another graph?
For example, for y = x2 the derivative w.r.t. x is y = 2x.

How can I do this ?

Eitan T
  • 32,660
  • 14
  • 72
  • 109
user559096
  • 107
  • 2
  • 8
  • you mean derivative? If you have symbolic toolbox, you can compute symbolic derivatives automatically for simple functions. – Memming Jul 01 '12 at 16:56
  • no, my curve is not simple. I just come a simple example! – user559096 Jul 01 '12 at 17:05
  • 1
    If you want numerical differentiation (not derivation), you can simply use http://en.wikipedia.org/wiki/Numerical_differentiation Try using `diff`. – Memming Jul 01 '12 at 17:07

1 Answers1

4

I do not understand the '3D' part. Why is y=x^2 a 3D curve?

But if you want to plot y=x^2 and its derivative on the same plot, use ezplot

clear all; close all;
syms x 
y=x^2;
h=ezplot(y,[-6,6]);
set(h, 'Color', 'r'); 
hold on;
ezplot(diff(y,x),[-6,6]);

enter image description here

Nasser
  • 12,849
  • 6
  • 52
  • 104