plot x axis with date string from cell array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I am plotting a graph with x-axis with date string in this format ('12/19/16 0:00', '12/20/16 10:30'). X-axis values are stored in 47040 * 1 cell array, and I picked representative 5 values to put on X-axis. However, it only outputs first value of an array.
Do you see why it is printing this way?
figure;
for k=1:7
diffSum = 0;
for i=(1+(k-1)*size(c,1)):(k*size(c,1))
diff = CumDiff(:,i);
diffSum = diffSum+ diff;
end
legend('-DynamicLegend');
plot(diffSum, 'color', rand(1,3), 'LineWidth', 3, 'DisplayName', sprintf('Group Thermal Comfort: %d', tc(k)));hold on;
legend('show');
drawnow;
end
xtickangle(45);
set(gca,'Xtick',1:10000:47040);
set(gca,'XtickLabel',datestr(out{1,1}(1:10000:47040)));
0 comentarios
Respuestas (1)
Walter Roberson
el 6 de Feb. de 2017
Try
set(gca, 'XtickLabel', cellstr( datestr(out{1,1}(1:10000:47040)) ) );
2 comentarios
Walter Roberson
el 6 de Feb. de 2017
set(gca, 'XtickLabel', {'12/19/16 0:00', '12/20/16 10:30', '12/21/16 23:15', '12/23/16 10:00', '12/24/16 22:45'} );
Remember, ['A', 'B'] for char means the same as ['AB'] which is 'AB'
The cellstr() was there to convert the char array produced by datestr() into a cell array of strings.
Ver también
Categorías
Más información sobre Labels and Annotations 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!