-1
だから私持っていたアクセルデータから平均値を計算するスクリプト:MathWorks社のMATLABでの平均値、最小値と最大値を計算する方法
clear all
close all
clc
load 'results.txt'
Fq=51.2;
N=length(results);
t= [1:N]/Fq;
plot (t,results);
role=results;
lowrow=role(1:9244,:);
fly=role(9245:18700,:);
pull=role(18802:28171,:);
subplot(3,1,1)
plot(lowrow)
xlabel('Samples'); ylabel('Acceleration'); title('High to Low Rows')
subplot(3,1,2)
plot(fly)
xlabel('Samples'); ylabel('Acceleration'); title('Reverse Fly')
subplot(3,1,3)
plot(pull)
xlabel('Samples'); ylabel('Acceleration'); title('Lawn Mower Pull')
windowLength = 5; %Length for each window in seconds
startPos = 1; %Starting Position for 1st win
endPos = startPos + (windowLength * floor(Fq)); %End Position for 1st win
totalWindows = floor(length(lowrow)/Fq/windowLength);
stats = zeros(windowLength,9);
for i = 1:totalWindows
epMean = mean(lowrow(startPos:endPos,:)); %calculate window mean
%X, Y & Z axis values for each stat
lowrowfeatures(i,1:3) = epMean;
%Next window position
startPos = endPos+1;
endPos = startPos + (windowLength * floor(Fq));
end
windowLength = 5; %Length for each window in seconds
startPos = 1; %Starting Position for 1st win
endPos = startPos + (windowLength * floor(Fq)); %End Position for 1st win
totalWindows = floor(length(fly)/Fq/windowLength);
stats = zeros(windowLength,9);
for i = 1:totalWindows
epMean = mean(fly(startPos:endPos,:)); %calculate window mean
%X, Y & Z axis values for each stat
flyfeatures(i,1:3) = epMean;
%Next window position
startPos = endPos+1;
endPos = startPos + (windowLength * floor(Fq));
end
windowLength = 5; %Length for each window in seconds
startPos = 1; %Starting Position for 1st win
endPos = startPos + (windowLength * floor(Fq)); %End Position for 1st win
totalWindows = floor(length(pull)/Fq/windowLength);
stats = zeros(windowLength,9);
for i = 1:totalWindows
epMean = mean(pull(startPos:endPos,:)); %calculate window mean
%X, Y & Z axis values for each stat
pullfeatures(i,1:3) = epMean;
%Next window position
startPos = endPos+1;
endPos = startPos + (windowLength * floor(Fq));
end
save('wekafile.txt','lowrowfeatures','flyfeatures','pullfeatures','-ascii')
私は平均が、最小値と最大値は、すべてのスクリプトにする必要があります知っているがIこれをどうやって行うのか分かりません。私はこれをjffツリーを見るarffファイルとしてwekaに入れます。
種類がみなし:)
あなただけ(!でもインデントない)コードの束をダンプして、どこまでもあなたのコードでは、あなたがこれらの計算をやりたいの変数に言及せず、完全に些細なタスクを実行する方法を求めることはできません。 'mean'、' min'、 'max'はすべて組み込みのMATLAB関数なので、実際にどのような問題がありますか? – Dan
Dan、ご返信ありがとうございます。私が抱えている問題は私の質問の中にあります:) – laurajs
もしそうなら、誰もそれを見つけられないように、フォーマットされておらず無関係なコードに深く埋もれています。 [ask]と[MCVE](http://stackoverflow.com/help/mcve)の作成方法を読んでください。あなたの場合、Mに焦点を当てる必要があります(無関係なコードをすべて削除します)。 – Dan