multiple sine wave adding and ploting
조회 수: 12 (최근 30일)
이전 댓글 표시
Hi every body .. i need help.. i was going to answer the following code of my matlab beginner lessons, so i confused as i'm new to the coding .. Actually i would appreciate if some one could help me.. this the question..
Write a function called mix_sines that takes two positive scalar input arguments f1 and f2 (you do not have to check the input arguments) that represent the frequency of two sines waves. The function needs to generate these sines waves, add them together and plot the result. If the function is called like this: mix_sines(1,0) then it displays three full periods of a regular sine wave with amplitude 1. If it is called like this: mix_sines(20,21), then it plots Figure 2.21 below (note that if you add a phase shift of pi to one of the sines, then the result will start at 0 as shown below). Notice that the amplitude is 2. Also, notice that signal has three times 21 periods, but the envelope signal has three times 1 periods. That is because the difference of the two frequencies (21 and 20) is 1. ? Figure 2.20 Problem 8 Figure.. i posted the fig8 below here.
댓글 수: 1
Star Strider
2017년 4월 29일
In the images, the two different frequency sine functions are being multiplied, not added.
You need to clarify this assignment.
채택된 답변
Image Analyst
2017년 4월 29일
편집: Image Analyst
2017년 4월 29일
Hints: formulas for sine wave
y = sin(2*pi*f*(x-phaseShift));
y = amplitude * sin(2*pi*(x-phaseShift)/period);
and period = 1/f. Compute x using linspace():
x = linspace(0, 3*period, 500); % 500 points between 0 and 3*period
and of course use plot(), and to get even fancier, use title, xlabel, ylabel and grid.
xlabel('X', 'FontSize', 20);
ylabel('Y', 'FontSize', 20);
title('My Awesome Homework Solution', 'FontSize', 20);
grid on;
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!