フィルターのクリア

Array indices must be positive integers or logical values.

2 ビュー (過去 30 日間)
Jay Wagh
Jay Wagh 2022 年 7 月 10 日
回答済み: Dhritishman 2022 年 7 月 10 日
z=0;
z1=0;
aa=zeros(3,3);
for i=1:k
z=z+t(i);
z1=z1+t(i-1);
aa(1,1)= aa(1,1) + (Qbar(1,1)*((-(T*0.5)+z)-(-(T*0.5)+z1)));
end

回答 (2 件)

Karim
Karim 2022 年 7 月 10 日
The following part of you code can produce an error: i starts at 1, hence you are trying to acces t(0) which is not possible. In matlab the indexing starts at 1, hence the first element in the array t will be t(1)
for i = 1:k
...
z1 = z1+t(i-1);
...
end

Dhritishman
Dhritishman 2022 年 7 月 10 日
z1=z1+t(i-1);
In your code, the value of i starts at 1, so t(i-1) will be trying to access t(0) which MATLAB doesn't allow as indexing should start from 1. Hence, it throws an error. The first element in the array t will be t(1), not t(0).

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by