필터 지우기
필터 지우기

Average numbers in array

조회 수: 1 (최근 30일)
Krasimir Terziev
Krasimir Terziev 2021년 8월 4일
댓글: Krasimir Terziev 2021년 8월 4일
Hello,
I've got an array with 65926x2 values. I try to make average when the 1st column got numer of 600 and write in the a new array as 1st cell. Then i want a next average till the numer of 1st column is 1200. What i mean is the time_space_average=[0:600:604800];
So at the end i want to have an array with 1009x1 elements. i will put excel table and picture of the data arrays!
Thanks in advance!

답변 (1개)

KSSV
KSSV 2021년 8월 4일
You may proceed some like this shown below:
T = readtable('C:\Users\KSSV\Downloads\1.xlsx') ;
x = T.(1) ; y = T.(2) ;
idx = 0:600:604800;
[c,ia] = ismember(idx,x) ;
n = length(ia);
iwant = zeros(n-1,2) ;
for i = 1:n-1
iwant(i,:) = [idx(i) mean(y(i:i+1))] ;
end
  댓글 수: 1
Krasimir Terziev
Krasimir Terziev 2021년 8월 4일
Hello,
Thanks for the fast answer!
I've got a different answers from that code.
What i mean is 1st.
i change this -> x = T.(1) ; y = T.(2) ; to this -> x = T(:,1); y = T(:,2);
so after that change, the code worked, but
the answer of "iwant" is from 0 to 604200 (not to 604800) - > it can be from 600 ( because average of one number at the zero is the same number) till 604800 including.
and the last one:
When i make average of the numbers in excel table -> there is not equal between the iwant 2nd column = 600 - 233.637405484499 and the table 600 - 233.790024856455.
i will put the same table with 2 average calculations, so the logic have to be the same.
If i miss somethink, just tell me :) im newbie at coding
i will wait for ur respon.
Thanks again!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by