If you must use a loop, you need to index into it:
M=0.5;
A=0.5;
Fm=1;
Fc=100;
x=0:0.0001:1;
for k1 = 1:numel(x)
y(k1) = (1+M*sin(2*pi*Fm*x(k1)))*(A*sin(2*pi*Fc*x(k1)));
disp(y)
end
However if you wnat one vector for ‘y’ it is better to use vectorized code:
x=0:0.0001:1;
y=(1+M*sin(2*pi*Fm*x)).*(A*sin(2*pi*Fc*x));
Both produce the same result. The second is much faster and more efficient.
Best Answer