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

4 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 31 Mai 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 Kommentare
Image Analyst
Image Analyst am 1 Jun. 2015
Bearbeitet: Image Analyst am 1 Jun. 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 am 2 Jun. 2015
Bearbeitet: Sidhant Guliani am 2 Jun. 2015
can you help me in writing the code for above mention 9 points.?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by