Hi !!! what is wrong in my code ??
Mostrar comentarios más antiguos
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)')
Respuestas (2)
Star Strider
el 13 de Dic. de 2020
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 comentarios
Titu talukder
el 13 de Dic. de 2020
Star Strider
el 13 de Dic. de 2020
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
el 13 de Dic. de 2020
Star Strider
el 13 de Dic. de 2020
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
el 13 de Dic. de 2020
Star Strider
el 13 de Dic. de 2020
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
el 13 de Dic. de 2020
That code ↓ should do what you want. It really was not that difficult!
Titu talukder
el 13 de Dic. de 2020
0 votos
Categorías
Más información sobre Performance and Memory en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!