- 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!