Identifying Maximum, Minimum, and Average Values from CSV

15 views (last 30 days)
I have a series of CSV files, comprising of 10 seconds of data taken at 20Hz of an inconsistently oscillating electromagnet - with clipping in some of the data sets. I need to identify the maximum and minimum values, as well as the two mean values (one positive, the other negative), and I need the values to display in a plot of the data.
I've worked with CSVs in matlab before, and I've done min/max matlab before, but I am having trouble getting some of the peaks to associate properly (where there is clipping), and can't figure out how to get the values of the peaks to be labeled in plots. Nor have I had much luck in getting averages for values above zero, and values below zero to be displayed (I'm picturing a horizontal line - but a simple readout in a legend, or similar, would also work)
%%Outter Diameter 1%%
Array = csvread('ULPR_Magnet-OD_Strength.csv');
time = Array(:, 1);
mT = Array(:, 2);
[Maxima,MaxIdx] = findpeaks(mT, 'MinPeakDistance', 163);
figure
plot(time, mT, time(MaxIdx),Maxima,'or')
title('Toroidal Testing Magnet - Outside Diameter Field Strength')
xlabel('Time (s)')
ylabel('Magnetic Field (mT)')

Answers (0)

Community Treasure Hunt

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

Start Hunting!