フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

WHY THIS ERROR OCCUR ''??? Subscript indices must either be real positive integers or logicals."

1 回表示 (過去 30 日間)
nadine
nadine 2012 年 11 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
t=-5 :0.1 :10;
h2=zeros(size(t));
h1=zeros(size(t));
z=zeros(size(t));
z=1*(t==0);
h2(t>=0)=exp(-t(t>=0));
h1(t>=0)=exp(-2*t(t>=0));
y1=conv(z,h1);
tn=t(1)+t(1):.1:t(end)+t(end);
y3=conv(z,h2);
y(tn)=y1+y3;
plot(tn,y);
hold on
y2(tn)=h1+h2;
plot(tn,y2)
ylabel('y1(t)=x(t)*h(t)');
xlabel('time[sec]');
grid;

回答 (2 件)

Kye Taylor
Kye Taylor 2012 年 11 月 6 日
編集済み: Kye Taylor 2012 年 11 月 6 日
Rethink how you're defining/using the variable
tn

Wayne King
Wayne King 2012 年 11 月 6 日
編集済み: Wayne King 2012 年 11 月 6 日
The problem is that you have a vector, tn, that goes in increments of 0.1, but you cannot access elements of another vector y() using that.
The elements of y() have to be accessed using a positive integer between 1 and the length of y.
For example,
y = randn(100,1);
y(5:10)
You are trying to do this:
y(3.1)

Community Treasure Hunt

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

Start Hunting!

Translated by