Info

This question is closed. Reopen it to edit or answer.

Can please somebody check my code and tell me what I ma doing wrong. I am trying to write a code for AM modulated wave of amplitude A to plot N element array of displacement values.

1 view (last 30 days)
delta_t=1/f_s start=0 step=t stop=(N-1)*delta_t t=start:step:stop A=input('enter amplitude of the wave'); fmod=input('enter modulation frequency'); fsig=input('enter signal frequency'); ym=A*sin(2*pi*fmod*t); ys=sin(2*pi*fsig*t); y=(A+ym)*sin(2*pi*fsig*t) subplot(3,1,1) plot(t,y);

Answers (1)

Jacob Ward
Jacob Ward on 5 Sep 2017
Edited: Jacob Ward on 5 Sep 2017
First off, please try to stick to the guidelines for posting questions to this site. See this answer for help in that area:
While it's a little bit unclear what you are asking for, changing the multiply to a dot multiply in the line y=(A+ym).*sin(2*pi*fsig*t) got rid of the errors that I was seeing and at least produced some results. See below:
f_s = 200;
t = .1;
N = 2000;
delta_t=1/f_s;
start=0;
step=t;
stop=(N-1)*delta_t;
t=start:step:stop;
A=input('enter amplitude of the wave');
fmod=input('enter modulation frequency');
fsig=input('enter signal frequency');
ym=A*sin(2*pi*fmod*t);
ys=sin(2*pi*fsig*t);
y=(A+ym).*sin(2*pi*fsig*t); % I changed the * in this line to a .*
% I also removed the subplot command because it's not needed
plot(t,y);
Is this what you were looking for?

This question is closed.

Community Treasure Hunt

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

Start Hunting!