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

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 31 Mag 2015
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 Commenti
Image Analyst
Image Analyst il 1 Giu 2015
Modificato: Image Analyst il 1 Giu 2015
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by