I want to plot the Point directly on the highest point of the graph

5 Ansichten (letzte 30 Tage)
I'd like some advice on how to do something like the plots below.
function MaxPower = partAQ2(ElectricalData)
%Creates a plot and shows the maximum power on a graph Power vs Time.
data = ElectricalData;
time = data(:,1); %extracts all the 1st column and transpose (s)
volts = data(:,2); %extracting all the 2nd column and transpose (V)
amps = data(:,3); %extracting all the 3rd column and transpose (A)
Power = amps.*volts; %element wise so it can multiply each by each, creating power
MaxPower = max(Power);
%plotting power vs time graph first
plot(time,Power); % time vs power.
hold on %allows for more to me added
grid on %I like grids
plot(time(end),MaxPower,'or','MarkerFaceColor', 'r'); %not sure how to select a single number, internet research was useless.
xlabel('time (s) ');
ylabel(' Power (W) ');
title( ' Power Used Over Time Drawn From Robot ');
legend('Power Over Time' , 'Maximum Power Drawn ','Location', 'west' ); %some reason the legend blocks the plot.
hold off %stop holding
end
I want it do something like this
While my code is doing this, and can anyone suggest how to make the circle hollow like that in my code?

Akzeptierte Antwort

Bhaskar R
Bhaskar R am 6 Mär. 2020
Bearbeitet: Bhaskar R am 6 Mär. 2020
[MaxPower, MaxPow_loc] = max(Power); % then apply
hold on;
plot(MaxPow_loc,MaxPower,'or','MarkerFaceColor', 'r', 'MarkerSize',10);

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by