Hi !!! what is wrong in my code ??
이전 댓글 표시
give me code of s(t) = cos(2*Π*100*t) + cos(2*Π*200*t).
t = 0:.01:1 % independent (time) variable
A = 8; % amplitude
f_1 = 2; % create a 2 Hz sine wave lasting 1 sec
s_1 = A*sin(2*pi*f_1*t);
f_2 = 4; % create a 4 Hz sine wave lasting 1 sec
s_2 = A*sin(2*pi*f_2*t);
%plot the 2 Hz sine wave in the top panel
subplot(3,1,1) ,plot(t, s_1)
title('2 Hz sine wave')
ylabel('Amplitude')
%plot the 4 Hz sine wave in the middle panel
subplot(3,1,2) , plot(t, s_2)
title('4 Hz sine wave')
ylabel('Amplitude')
%plot the summed sine waves in the bottom panel
subplot(3,1,3) , plot(t, s_1+s_2)
title('Summed sine waves')
ylabel('Amplitude')
xlabel('Time (s)')
답변 (2개)
Star Strider
2020년 12월 13일
It appears to run without error and gives what I consider the appropriate result.
What problems are you having with it?
If you want to plot:
give me code of s(t) = cos(2*Π*100*t) + cos(2*Π*200*t).
instead, make the appropriate substitutions for ‘A’, ‘f_1’, and ‘f_2’ in the code you posted, and change the sin calls to cos calls.
댓글 수: 7
Titu talukder
2020년 12월 13일
Star Strider
2020년 12월 13일
Note that ‘A’ is the amplitude and ‘f_1’ and ‘f_2’ are the frequencies.
Look at ‘c_1’ and ‘c_2’ and make the appropriate substitutions, using the information in ‘s(t)’.
Titu talukder
2020년 12월 13일
Star Strider
2020년 12월 13일
Since this appears to be homework, the policy on MATLAB Answers is not to provide working code for homework problems.
The code you were given is in the context of:
Amplitude * cos(2*pi*Frequency*t)
for each term.
I will let you take it from there.
Titu talukder
2020년 12월 13일
Star Strider
2020년 12월 13일
I have given you all the help I can possibly give without writing the code for you.
Please re-read what I wrote and experiment using the hints I have provided.
Star Strider
2020년 12월 13일
That code ↓ should do what you want. It really was not that difficult!
카테고리
도움말 센터 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!