Info
此问题已关闭。 请重新打开它进行编辑或回答。
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 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
Jacob Ward
2017-9-5
编辑:Jacob Ward
2017-9-5
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?
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!