How can I solve this error when I use Trapz ?

4 ビュー (過去 30 日間)
ibrahim alzoubi
ibrahim alzoubi 2020 年 4 月 17 日
コメント済み: Ameer Hamza 2020 年 4 月 17 日
I keep getting this error when I run my program.
err = 1-y; %Define error signal
t = 0 : 0.01 :30;
ise = trapz (1,err.^2);
-------
Error using trapz (line 47)
Dimension argument must be a positive integer scalar within indexing range.
Undefined operator '.^' for input arguments of type 'timeseries'.
y here is output data from a block diagarm simulink.
any solutions?
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 17 日
Can you tell us the value of variable 'y'?
ibrahim alzoubi
ibrahim alzoubi 2020 年 4 月 17 日
This is y, its an output for a block diagram.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 17 日
Try this
err = 1 - y.Data; %Define error signal
ise = trapz(y.Time, err.^2);
  2 件のコメント
ibrahim alzoubi
ibrahim alzoubi 2020 年 4 月 17 日
編集済み: ibrahim alzoubi 2020 年 4 月 17 日
It worked. Thanks alot.
I really appreciate your kind repsones.
Ameer Hamza
Ameer Hamza 2020 年 4 月 17 日
I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by