using syms x to create an equation Y(x), then letting x be a vector to plot, x vs Y

조회 수: 2 (최근 30일)
using syms x I have created an equation
Y = (x/20 - 2)*(x/40 - 1) - (x/20 - 1)^2 + x^2/800
I would now like to set x = to a vector say [0:0.1:40] and would like plot(x,Y)
how can i implement this because when i try plot(x,Y) i get an error of
EDU>> plot(x,Y) ??? Error using ==> plot Conversion to double from sym is not possible.

채택된 답변

Walter Roberson
Walter Roberson 2013년 10월 27일
편집: Walter Roberson 2013년 10월 27일
xvals = 0:0.1:40;
plot(xvals, double(subs(Y, x, xvals)))
  댓글 수: 3
Nicholas
Nicholas 2013년 10월 27일
i tried it with other functions and it seems to work i dont know why my equation is linear but thank you
Walter Roberson
Walter Roberson 2013년 10월 28일
That equation does evaluate to 1. Expand the first multiplication, expand the squared term, add the two together, then note that the x^2 term cancels with the remaining term in Y, leaving just 1.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by