Error plotting my graph.

조회 수: 9 (최근 30일)
Adam Makin
Adam Makin 2017년 12월 4일
답변: Star Strider 2017년 12월 4일
This is my code. The error is: Error using plot Data must be numeric, datetime, duration or an array convertible to double. I am not sure what is causing this.
t = [0:0.1:6*pi];
syms k omega t
S1 = symsum(cos(2*k*omega*t)/(4*k^2 - 1) , k,[1; Inf]);
y = 1/pi + 0.5*sin(omega*t) - (2/pi)*S1;
plot(t,y)
  댓글 수: 3
Adam Makin
Adam Makin 2017년 12월 4일
y should just be a number(float) dependent on t. Then im plotting against multiple values of t so a vector?
Greg
Greg 2017년 12월 4일
편집: Greg 2017년 12월 4일
class(y)
"Vector" is not a data type, it's a shape.

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

답변 (1개)

Star Strider
Star Strider 2017년 12월 4일
Use fplot (with a single value for ‘omega’) or fsurf (with a range of values for ‘omega’).
This works:
syms k omega t
S1 = symsum(cos(2*k*omega*t)/(4*k^2 - 1) , k,[1; Inf]);
y(t,omega) = 1/pi + 0.5*sin(omega*t) - (2/pi)*S1;
fplot(y(t, pi/6), [0 6*pi])
I tried fsurf as well, however it takes forever so I stopped it.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by