a = [1 2 13 20 10 20 12 1 13 14]
b = [1:10:100]
积(A,B) 我想从图中找到最大值('a')然后取相应的点让'a3,b3'并将其存储在其他地方并将其从图中删除。然后我想从'a'中剩下的每个点中减去'a3'并绘制图形。我需要再次这样做,直到它达到一个阈值保持点。
答案 0 :(得分:0)
这似乎是一个奇怪的请求,但如果我理解正确的话。
%Input data
a = [1 2 13 20 10 20 12 1 13 14];
b = [1:10:100];
%Some threshold (which you didn't specify
lengthA = 4;
%Initialize storage vector
aPrime = a;
bPrime = b;
%While vector
while (length(aPrime) >= lengthA)
%New figure
figure;
%Plot vector
plot(aPrime, bPrime)
%Find index and max value in a'
[aMax, index] = max(aPrime);
%Find max value in b'
bMax = bPrime(index);
%Remove max value from vector and subtract off max value
aPrime = aPrime([1:index - 1, index + 1:end]) - aMax;
bPrime = bPrime([1:index - 1, index + 1:end]) - bMax;
end