簡體   English   中英

從圖/圖中找到最大點

[英]to find maximum point from the graph/plot

a = [1 2 13 20 10 20 12 1 13 14]

b = [1:10:100]

plot(a,b)我想從圖中找到最大值('a'),然后取相應的點,假設說'a3,b3',並將其存儲在其他位置,然后從圖中刪除。 然后我想從'a'中剩余的每個點中減去'a3'並繪制圖表。 我需要再次執行此操作,直到達到脫粒保持點為止。

這似乎是一個奇怪的要求,但如果我理解正確的話。

%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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM