I have two vectors (x and y) of the same size with x having more than one value in the y direction. For example, x is [0.02 0.02 0.03 0.03 0.03 0.04 0.04 0.05 0.05 0.05] and y is [0.23 0.40 0.12 0.16 0.09 0.50 0.02 0.33 0.10 0.08]. I want to convert the attached scattered plot of the two vectors to a simple continuous curve, by evaluating the integral average of y values with respect to x values. Take into account that the x vector is already ordered from small to large values. How could I do this?
John Michell answered .
2025-11-20
x = [0.02 0.02 0.03 0.03 0.03 0.04 0.04 0.05 0.05 0.05]; y = [0.23 0.40 0.12 0.16 0.09 0.50 0.02 0.33 0.10 0.08]; I = cumtrapz(x,y); % Integrated Vector Of ‘y’ w.r.t. ‘x’ figure(1) plot(x, I) grid