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!