How do I just plot a single specific point on a graph?? No answers on here have been helpful!
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
William Grant
el 6 de Mzo. de 2020
Comentada: William Grant
el 6 de Mzo. de 2020
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
0 comentarios
Respuesta aceptada
dpb
el 6 de Mzo. de 2020
"want to only plot the maximum power"
...
Power=amps.volts;
[Pmax,imax]=max(Power);
plot(time(imax),Pmax,'or','MarkerFaceColor','r')
...
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!