I'm really not good at this. "Array indices must be positive integers or logical values." What is wrong?

1 回表示 (過去 30 日間)
n1=-10:-1;
n2=0:10;
n=[n1 n2];
u1=ones(size(n2));
u2=zeros(size(n1));
u=[u1 u2];
h1=abs(-1-3)*(u(-1)-u(-1-6));

採用された回答

Star Strider
Star Strider 2023 年 1 月 23 日
I suspect you want to define ‘u’ as a unit step function. This does that (and solves the ‘u’ error) however it gives a likely undesired result.
n1=-10:-1;
n2=0:10;
n=[n1 n2];
u = @(t) t>0; % Simple Unit Step Function
u1=u(n2);
u2=u(n1);
uv=u([u1 u2]);
h1=abs(-1-3).*(u(-1)-u(-1-6))
h1 = 0
.
  2 件のコメント
Nico A
Nico A 2023 年 1 月 23 日
Oh thank u so much, it works
Star Strider
Star Strider 2023 年 1 月 23 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by