Hello Community, I got a problem using datetick in my figure. Here is what I want:
-time printed on my x-axis as "lap time" using the format "MM:SS" with speed on y-axis
Here is my code so far:
tsec=time_s(1:5266,1);v_soll=v_target_kmph(1:5266,1);axes1 = axes;hold(axes1,'on');plot(tsec,v_soll,'DisplayName','Speed','LineWidth',2);xlabel('Time [mm:ss]','FontSize',14,'Interpreter','latex');dateFormat = 15; % or dateFormat = 'MM:SS';
datetick('x',dateFormat, 'keeplimits', 'keepticks')ylabel({'Speed [kmh]'},'FontSize',14,'Interpreter','latex'); xlim(axes1,[0 530.893315881894]); ylim(axes1,[0 300]); box(axes1,'on');set(axes1,'FontName','SansSerif');
tsec looks like this:
00.1000000000000000.2000000000000000.3000000000000000.4000000000000000.5000000000000000.6000000000000000.7000000000000000.8000000000000000.90000000000000011.100000000000001.200000000000001.300000000000001.400000000000001.500000000000001.600000000000001.700000000000001.800000000000001.9000000000000022.10000000000000...... (until)526.500000000000
Using datestr(tsec/24/3600, 'MM:SS'); makes it correctly displayed as I want it but I cant use that in the plot (i.E. 08:46)
Using the Code above gives me the following result attached in file
Best Answer