How do I just plot a single specific point on a graph?? No answers on here have been helpful!
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2020-3-6
"want to only plot the maximum power"
...
Power=amps.volts;
[Pmax,imax]=max(Power);
plot(time(imax),Pmax,'or','MarkerFaceColor','r')
...
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!