How can I solve this error when I use Trapz ?

1 view (last 30 days)
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 Comments
Ameer Hamza
Ameer Hamza on 17 Apr 2020
Can you tell us the value of variable 'y'?
ibrahim alzoubi
ibrahim alzoubi on 17 Apr 2020
This is y, its an output for a block diagram.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 17 Apr 2020
Try this
err = 1 - y.Data; %Define error signal
ise = trapz(y.Time, err.^2);
  2 Comments
ibrahim alzoubi
ibrahim alzoubi on 17 Apr 2020
Edited: ibrahim alzoubi on 17 Apr 2020
It worked. Thanks alot.
I really appreciate your kind repsones.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!