System unit-impulse response for given tau

8 ビュー (過去 30 日間)
Thomas Marshall
Thomas Marshall 2019 年 11 月 18 日
編集済み: M 2019 年 11 月 20 日
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 Center および File ExchangePlot Customization についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by