MATLAB Answers

0

Is this code ok?It asked to plot function together with hold on...syms x y; t=-2:0.1:2 n=-2:0.1:2 x=2*sin(4*pi*t); y=2*sin(4*pi*n); plot(t,x,'r',n,y,'g'); hold on; title('function'); legend('x function', 'y function'); grid on;

nickey 님이 질문을 제출함. 23 Apr 2013
Is this code ok?It asked to plot function together with hold on. But when I run code,I have just y function ?
syms x y;
t=-2:0.1:2
n=-2:0.1:2
x=2*sin(4*pi*t);
y=2*sin(4*pi*n);
plot(t,x,'r',n,y,'g');
hold on;
title('function');
legend('x function', 'y function');
grid on;

  댓글 수: 0

로그인 to comment.

답변 수: 2

Walter Roberson 님의 답변 23 Apr 2013

You only get one plot line because your "t" and "n" are the same, and you apply the same formula to each of them, so the results are identical.

  댓글 수: 0

로그인 to comment.


bym 님의 답변 23 Apr 2013

  • no need for syms x y
  • x & y are the same thing
perhaps you meant
y = 2*cos(4*pi*t)

  댓글 수: 0

로그인 to comment.



Translated by