Hi there! I'm somewhat new to using MATLAB and wanted to know what commands would help me create a script like this:
I have a set of 5 data points that look like this:
x = [40 ; 43 ; 50; 52; 60]
y = [12 ; 15 ; 20; 21; 26]
I want to create a script that I can apply to any set of data such that if the difference between consecutive x-values is less than 3, only keep the data point that has a larger y-value. On the other hand, if the consecutive x-values are greater than or equal to 3, keep both points as part of the data set. I tried using a for loop and an if statement to create a script that looks like this but am unsure what should go after the difference function to keep both data points included. Likewise, how should I format the code after the else statement to account for the scenario in which the consecutive x-value difference is less than 3 and should only keep the data point with the higher y-value?
for ii = x