O osman82 New Member Mar 28, 2009 #1 need to generate the following signal in matlab...anybody can help?? x(t)=exp(-0.1t) Sin0.6t for t= 0 to 40ms in steps of 0.1 sec. thanks people
need to generate the following signal in matlab...anybody can help?? x(t)=exp(-0.1t) Sin0.6t for t= 0 to 40ms in steps of 0.1 sec. thanks people
S Speakerguy Active Member Mar 28, 2009 #2 t = 0:.0001:40; x = e.^(-.1*t) * sin(0.6*t) try that for starters. the equation may need some work. i also assume you meant 0.1ms not 0.1s. Last edited: Mar 28, 2009
t = 0:.0001:40; x = e.^(-.1*t) * sin(0.6*t) try that for starters. the equation may need some work. i also assume you meant 0.1ms not 0.1s.
T tboydva Member Mar 29, 2009 #3 Probably a way to vectorize without a loop, but this would do it: create a function: Code: function output = sig_gen(input) for x = 1:length(input) output(:,x) = exp(-0.1*(input(:,x))) * sin(0.6 * input(:,x)); end Then call: Code: signal = sig_gen(0:0.1:40); then you could plot: Code: plot(0:0.1:40,signal); or in one step: Code: plot(0:0.1:40, sig_gen(0:0.1:40));
Probably a way to vectorize without a loop, but this would do it: create a function: Code: function output = sig_gen(input) for x = 1:length(input) output(:,x) = exp(-0.1*(input(:,x))) * sin(0.6 * input(:,x)); end Then call: Code: signal = sig_gen(0:0.1:40); then you could plot: Code: plot(0:0.1:40,signal); or in one step: Code: plot(0:0.1:40, sig_gen(0:0.1:40));