필터 지우기
필터 지우기

How can I plot a sym variable?

조회 수: 1 (최근 30일)
Kavan
Kavan 2013년 3월 4일
I am trying to plot a function and it's derivative, but
syms x y
y=4*x*cos(x)+2*x^cos(x^2)
dydx=diff(y)
plot(y)
gives me an error that I cannot convert double to sym. I know I can plot a function and its derivative using LINSPACE but I want the analytical derivative value as well. How can I plot y and dydx? I also know I can use "EZPLOT" but that doesn't let me do very much with the plotter. Is it possible to plot a symbolic variable and if it is now, how do I get an analytical derivative AND plot it in MatLab?
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 3월 4일
The analytic derivative will be a formula, and you cannot plot() a formula. You could put the formula up as text using text()

댓글을 달려면 로그인하십시오.

채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 3월 4일
hi did you try this :
syms x y dy
y=4*x*cos(x)+2*x^cos(x^2)
dy=diff(y,1);
figure, ezplot(y); hold on; ezplot(dy);
  댓글 수: 2
Kavan
Kavan 2013년 3월 4일
yes, but I don't want to use EZPLOT because I can't change the color of the plot
Youssef  Khmou
Youssef Khmou 2013년 3월 4일
and if you move back to numeric ? fine ?
xAxis=[0:0.1:10];
Y=subs(y,xAxis);
DY=subs(dy,xAxis);
figure, plot(Y), hold on, plot(DY,'r')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by