Effacer les filtres
Effacer les filtres

How do I just plot a single specific point on a graph?? No answers on here have been helpful!

2 vues (au cours des 30 derniers jours)
So "plot(time,Power,'o'); %not sure how to select a single number" will show specific points, and It would help if you ran this code to see what I meant, and use "partAQ2([0,5,2;1,3,4;2,5,8])" to call the function so we're on the same page.
I just want to only plot the maximum power, which in this case is 40W. I want to do this in CODE not in the editor which I don't know how to use anyway. If anyone has any suggestions I'd appreciate it.
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
%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,Power,'o'); %not sure how to select a single number
xlabel('time (s) ');
ylabel(' Power (W) ');
title( ' Power Used Over Time Drawn From Robot ');
hold off %stop holding
end

Réponse acceptée

dpb
dpb le 6 Mar 2020
"want to only plot the maximum power"
...
Power=amps.volts;
[Pmax,imax]=max(Power);
plot(time(imax),Pmax,'or','MarkerFaceColor','r')
...

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