how to define time matlab for bar graph

2 views (last 30 days)
fastjokerB
fastjokerB on 2 Dec 2019
Commented: fastjokerB on 2 Dec 2019
I want to display the graph by time, but I can't define the time so the graph is incorrect.
this is time variables
ChargeTime=[14.25;14.30;14.35;14.40;14.45;14.50;14.55;15.00;
15.05;15.10;15.15;15.20;15.25;15.30;15.35;15.40;15.45;15.50;
15.55;16.00;16.05;16.10;16.15;16.20;16.25;16.30;16.35;16.40]
power [6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;0;0;0;0;0]
  2 Comments
Tiago Dias
Tiago Dias on 2 Dec 2019
Hello, your ChargeTime is not time, is just a number.
If you are fine with being a number just do
plot(ChargeTime,power,'*')
If u need time with days and hours and minutes:
t1 = datetime('26-09-2018 00:00:00','Format','dd-MM-uuuu HH:mm:ss','Format','dd-MM-uuuu HH:mm:ss');
fastjokerB
fastjokerB on 2 Dec 2019
hello, thank you for your answer. yes it is not time. how can I define time? 14.25 hours at 16.45 hours until the time changes. The story of the event comes to 3 vehicles such parking station and these vehicles are charging over time. I want to show the power change graphically.

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 2 Dec 2019
ChargeTime=[14.25;14.30;14.35;14.40;14.45;14.50;14.55;15.00;
15.05;15.10;15.15;15.20;15.25;15.30;15.35;15.40;15.45;15.50;
15.55;16.00;16.05;16.10;16.15;16.20;16.25;16.30;16.35;16.40];
power=[6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;0;0;0;0;0];
bar(power)
xticks([14.25;14.30;14.35;14.40;14.45;14.50;14.55;15.00;
15.05;15.10;15.15;15.20;15.25;15.30;15.35;15.40;15.45;15.50;
15.55;16.00;16.05;16.10;16.15;16.20;16.25;16.30;16.35;16.40])
xlim([14 16]);
This way?
  3 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 2 Dec 2019
Edited: KALYAN ACHARJYA on 2 Dec 2019
ChargeTime=[14.25;14.30;14.35;14.40;14.45;14.50;14.55;15.00;
15.05;15.10;15.15;15.20;15.25;15.30;15.35;15.40;15.45;15.50;
15.55;16.00;16.05;16.10;16.15;16.20;16.25;16.30;16.35;16.40];
power=[6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;6.6;0;0;0;0;0];
bar(power)
xticklabels({'14.25','14.30','14.35','14.40','14.45','14.50','14.55','15.00','15.05','15.10','15.15','15.20','15.25','15.30','15.35','15.40','15.45','15.50','15.55','16.00','16.05','16.10','16.15','16.20','16.25','16.30','16.35','16.40'})
Is this? If not can you show the expected results (you can use paint tool) or are you want time format in axis?
fastjokerB
fastjokerB on 2 Dec 2019
thank you, but I wrote a code in matlab and when I run this code I want this graph to run time-dependent.

Sign in to comment.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!