System unit-impulse response for given tau

4 次查看(过去 30 天)
I am having trouble trying to plot two impulse reponses based off of given tau values over the time interval 0 < t < 2. Below is what I have to start before plotting x1 and x2 vs time, t. I keep getting an error message based on t being a matrix and not being able to divide it by t in the response equations x1 & x2? How would I go about tyring to graph this and fix the time error that keeps generating?
tau1 = 0.25;
tau2 = 0.75;
A = randn(0,5);
t = 0:0.1:2
x1 = (A/tau1)*exp(t/-tau1)
x2 = (A/tau2)*exp(t/-tau2)
plot(t,x1(t))
subplot(t,x2(t))

回答(1 个)

M
M 2019-11-20
编辑:M 2019-11-20
There is a problem of dimensions for matrix multiplication at line 5 and 6 :
x1 = (A/tau1)*exp(t/-tau1)
x2 = (A/tau2)*exp(t/-tau2)
If you look at :
A_t = A/tau1
size(A_t)= 0 5
Because A = randn(0.5), but randn(M) returns an M-by-M matrix.
so inside the randn() function, you should select an integer value > 0.
Replace 0.5 by 1 should work.
Then you will have a problem when plotting.
Note that you do not need x1(t) but simply x1.
Finally, either use subplot for both x1 and x2 or use plot for both and see the hold command

类别

Help CenterFile Exchange 中查找有关 Acoustics, Noise and Vibration 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by