- readtable
- readmatrix
- mean, movmean (not sure how their time points will be used for averaging)
- interp1
averaging and interpolating random number of rows of data
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a list 800 particles data in an excel file. A total of 174755 rows...
Is there a way to extract these values and then average them based on their time point, later interpolate them based on the time point. I would like to average the first row of every particle 1,2,3....800. So after NaN, it will consider that as row 1,2,3...last number before NaN, then another row 1 again.
For example:
row 1 1 5
row 2 2 6
row 3 3 7
NaN
NaN
NaN
row 1 4 8
row 2 5 9
row 3 6 10
row 4 10 11
NaN
NaN
NaN
row 1 7 1
row 2 8 2
row 3 9 3
So the desired output average should be:
average of row 1 4 4.67
average of row 2 5 5.75
average of row 3 6 6.67
average of row 4 10 11
filename = 'plottemperature.xlsx';
T = xlsread(filename); %read excel file
[rows,columns] = size(T); %List the number of rows and columns
nanLocations = isnan(T); %declare all NaN locations in the excel file
for row = 1: rows
for col = 1:columns
if ~nanLocations(row,col) %I wanted to write it so that after the 3rd NaN it will be another row 1
%I am not sure how to continue from here to set the rows after every NaN as row 1 and then average all row 1
Please guide me. Thank you very much!
4 个评论
Adam Danz
2020-9-29
Unless you're using an old version of matlab, you sould not use xlsread. Instead, use one of the other functions recommended in the documentation. See the top of this page.
I didn't follow your averaging example. I can't imaging what would produce an avg of 4, for example.
回答(1 个)
Image Analyst
2020-9-29
Yes, try this (untested):
badRows = isnan(T{:, 1}); % Find nans in column 1.
T = T(~badRows, :); % Extract all rows except the bad rows.
3 个评论
Image Analyst
2020-9-30
Not sure I understand your new question. Please give an example input table and output table.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!