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

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Image Analyst
Image Analyst el 31 de Mayo de 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 comentarios
Image Analyst
Image Analyst el 1 de Jun. de 2015
Editada: Image Analyst el 1 de Jun. de 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.
Sidhant Guliani
Sidhant Guliani el 2 de Jun. de 2015
Editada: Sidhant Guliani el 2 de Jun. de 2015
can you help me in writing the code for above mention 9 points.?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by