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

5 vues (au cours des 30 derniers jours)
William Grant
William Grant le 6 Mar 2020
Modifié(e) : Bhaskar R le 6 Mar 2020
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?

Réponse acceptée

Bhaskar R
Bhaskar R le 6 Mar 2020
Modifié(e) : Bhaskar R le 6 Mar 2020
[MaxPower, MaxPow_loc] = max(Power); % then apply
hold on;
plot(MaxPow_loc,MaxPower,'or','MarkerFaceColor', 'r', 'MarkerSize',10);

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by