can someone help me debug this code to plot the graph of a function and its derivative?

clc
clear all
syms y x
x=linspace(-2,4,100);
y=3*x.^3-26*x+10
dy=diff(y,x)
ddy=diff(dy,x)
plot(x,y,x,dy,x,ddy)

回答(1 个)

You define a symbolic variable x and then immediately overwrite it with a numeric vector.
syms y x
x=linspace(-2,4,100);
Name this vector something else and use subs to substitute it in place of x in the expressions y, dt, and ddy when you want to plot them.

1 个评论

I dont really get how to implement what you said can you please send me the modified code.

此问题已关闭。

产品

版本

R2017a

关闭:

2021-8-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by