Identifying Maximum, Minimum, and Average Values from CSV
8 次查看(过去 30 天)
显示 更早的评论
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)')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148481/image.png)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!