您好我想找到一种方法来创建一个在MatLab中的矩阵,只有在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
感谢谁提前回复,
贾里德。
你试过只是写,做这样的功能?它看起来不那么难... – trutheality 2012-04-16 02:05:22
我已经尝试过,但我是与MatLab合作的新手。我认为我无意中创建了一个无限循环,因为MatLab被卡住为'Busy' – jazibobs 2012-04-16 02:07:37
你可以发布你已经尝试过的东西,并且有人可以帮助你... – trutheality 2012-04-16 02:09:03