I have a matlab plot(graph) x,y axis and i want to find the maximum from x axis. How to find that?

4 ビュー (過去 30 日間)
a= [1 2 13 20 10 20 12 1 13 14]
b= [1:10:100]
plot(a,b)
I want to find the maximum('a') from the plot and then take the corresponding point let say 'a3,b3' and store it some where else and remove it from the plot. then I want to subtract 'a3' from every point left in 'a' and plot the graph. and I need to do this again till it reaches an thresh hold point.

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 31 日
Try this demo and see if it does what you want (plotting, finding, saving, and removing max, then subtracting max from what's left).
fontSize = 24;
a= [1 2 13 20 10 20 12 1 13 14];
b= [1:10:100];
storedMaxima = zeros(1, length(a));
loopCounter = 1; % For storing the maxima
hFig = figure;
while ~isempty(a)
% Plot what we have.
plot(b, a, 'b*-', 'MarkerSize', 19, 'LineWidth', 2);
grid on;
xlabel('b', 'FontSize', fontSize);
ylabel('a', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% See if they want to quit now.
if length(a) > 1
promptMessage = sprintf('Do you want to Continue processing,\nor Quit?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(button, 'Quit')
break;
end
end
% Find the max
[maxValue, indexOfMax] = max(a);
% Store the maxima
storedMaxima(loopCounter) = maxValue;
loopCounter = loopCounter + 1;
% Remove the max
a(indexOfMax) = [];
b(indexOfMax) = [];
% Subtract the max from a.
a = a - maxValue;
end
% Print maxima to command window:
storedMaxima
uiwait(helpdlg('Done with demo.'));
close(hFig); % Close down figure.
  3 件のコメント
Image Analyst
Image Analyst 2015 年 6 月 1 日
編集済み: Image Analyst 2015 年 6 月 1 日
It looks like a different CLEAN algorithm than the famous one used in astronomy, but good luck with it. Let us know if you have any questions.
Sidhant Guliani
Sidhant Guliani 2015 年 6 月 2 日
編集済み: Sidhant Guliani 2015 年 6 月 2 日
can you help me in writing the code for above mention 9 points.?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by