Problems with drawing diagrams in MATLAB

I'm completely new to MATLAB, and I need help with diagrams. I have to compare and draw 3 different wave equations in one diagrams. How can I do so? Or if possible can anyone send the code? Here are the equations:
  1. Y1= 11.5sin((2πλ/4.97) + 63.3)
  2. Y2= 14.6sin((2πλ/10.5) + 45.8)
  3. Y3= 7.36sin((2πλ/4.97) + 63.3)

답변 (1개)

Nithin Banka
Nithin Banka 2018년 6월 8일

0 개 추천

Refer to Hold documentation. Example:
x = linspace(-pi,pi);
y1 = sin(x);
plot(x,y1)
hold on
y2 = cos(x);
plot(x,y2)
hold off

댓글 수: 3

Well I tried this:
.
x = linspace(-pi,pi);
y1= 11.5*sin((2*sin(pi)*lambda/4.97) + 63.3);
plot(x,y1)
hold on
y2 = 14.6*sin((2*sin(pi)*lambda/10.5) + 45.8);
plot(x,y2)
hold on
y3= 7.36*sin((2*sin(pi)*lambda/4.97) + 63.3);
plot (x,y3)
hold off
But I didn't get any results, since it gave this error:
.
Error using plot
Vectors must be the same length.
Error in Untitled (line 4) plot(x,y1) end
Nithin Banka
Nithin Banka 2018년 6월 12일
편집: Nithin Banka 2018년 6월 12일
The size of 'lambda' and size of 'x' must be same. Use size() function to find their sizes. Since in your case 'y1 or y2 or y3' does not depend on 'x' try changing the size of 'x'.
lambda = linspace(-pi,pi);
y1 = 11.5*sin(2*pi*lambda/4.97 + 63.3);
plot(lambda, y1)

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

카테고리

도움말 센터File Exchange에서 Language Fundamentals에 대해 자세히 알아보기

질문:

2018년 6월 8일

댓글:

2018년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by