필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

i need help with finding the right number by calculating the average between 2 set of points at a time

조회 수: 1 (최근 30일)
I've a project, and I'm new to matlab, never used it before this project. I'm trying to create a for loop with an if statment inside it. The for loop purpace is to find the average between 2 given points at a time form 8 values, and the "if" statement is to check if the the average is more than 1% greater than 119.2. If it is greater, then we need to use the average we just found, and find the average between the first point and the new point, until we find the correct answer, and then the loop can move on to the next set of points.
  댓글 수: 1
dpb
dpb 2020년 5월 11일
In MATLAB, more than likely you don't need the loop, but it's not clear precisely what you're looking for...
Attach a small sample dataset and show us the result you want for it...it can be 10 or so points, number of points is immaterial as long as it demonstrates the problem.

답변 (1개)

Image Analyst
Image Analyst 2020년 5월 11일
Put your signals into 8 rows of a matrix. Then to find the average of the 8 rows, you need to use mean
meanSignal = mean(allSignals, 1);
threshold = 1.01 * 119.2
for k = index1 : index2
% Find the mean value at index k;
meank = meanSignal(k);
if meank > threshold
% if it is greater then we need to use the average we just found
% and find the average between the first point and the new point
meanSignal(k) = mean(meanSignal(index1 : k)); % Replace with mean up until this index.
end
end

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by