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 CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by