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)
0 个评论
回答(1 个)
Steven Lord
2018-10-29
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 个评论
Reghunaath A A
2018-10-29
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!