# How to get the highest value from the latest samples? [MATLAB]

Thread Starter

#### Dragnovith

Joined Apr 16, 2021
22
I have code that calculates an error for each sample, and i would like to always get the highest value from the last samples.
Code:
error(n,1)=Ia(n)-Ia_future(n,1)
p(n,1) = (1+0.2)*max(error(n-1,1))
I want to get the maximum value of the last n samples of error(n-1,1) that were calculated.

Last edited: