I am writing a function which gives the frequency of the nth key of a piano. But I want the frequency to decay with time, like in real life. So I multiply my function with exp(-a * 5) where a is some number from 0 to 1. But it gives me an error:
Error using .*
Matrix dimensions must agree.
How can I solve this problem?
sr = 16000;
T = 2; % seconds duration
t = 0:(1/sr):T;
n = 1;
f = ((2^(1/12))^(n-49))*440;
a = 0:0.01:1;
y = exp(-a*5).*sin(2*pi*f*t);
plot(t, y);
