こんにちは私は、30秒間にわたって繰り返されるエクササイズの最大値と最小値のみを使用して、MatLabでマトリックスを作成する方法を見つけようとしています。
たとえば、データセットがある場合:
data = [1 3 5 7 9 6 4 2 3 6 8 10 7 6 4 2 1]
私が望んでいた結果は次のとおりです。
output = [1 9 2 10 1]
この関数は、絶えず変化する波形のピーク値のみをプロットします。
私が試したコードは次のとおりです。
size = length(data); %Get the length of the dataset
x = 1; %Set a counter value
maxplot = 0; %Default, a maximum value has not yet been plotted
for x = 1:size-1
a1 = data(1,x); %Get two adjacent samples of the dataset
a2 = data(1,x+1);
v = 1; %Set the initial column for the max points matrix
while maxplot == 0
if a1 > a2
max(v,1) = a1;
v = v + 1;
maxplot = 1;
end
end
if a1 < a2
maxplot = 0;
end
end
事前に返信してくださった方に感謝します。
ジャレド。