フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
eslam abuelnaga
eslam abuelnaga 2020 年 5 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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