Labeling the X axis in an hour format while original data points were gathered every 5 minuites

1 visualización (últimos 30 días)
close all
A = table2array(Aptamer);
Con=A(:,1);
Dr19=A(:,2);
Dr40=A(:,3);
Blank=A(:,4);
t=(1:length(Con));
plot(t,Con)
hold on
plot(t,Dr19)
plot(t,Dr40)
plot(t,Blank)
xlabel("Time")
ylabel("Fluorescence")
legend('Control','Dr19','Dr40','Blank')
I tried various ways to get my code to be formatted so that every 12 points showed up as one hour on the x axis including using time series and datenum with date tick. Does anyone know how to do this? Thanks in adavce

Respuesta aceptada

dpb
dpb el 8 de Jun. de 2022
Editada: dpb el 8 de Jun. de 2022
Aptamer.Time=minutes(5*[0:height(Aptamer)-1]); % create the time vector at 5 min
Aptamer.Time.Format='h'; % display hours/fractions thereof
plot(Aptamer.Time,Aptamer{:,1:4})
xlim([Aptamer.Time(1) Aptamer.Time(1)])
xlabel("Time")
ylabel("Fluorescence")
legend('Control','Dr19','Dr40','Blank')
You've already got the data in a table; use it, don't make new variables for no purpose. Not knowing the variable names I use the {} syntax to pull the four columns all rows.
Create the time vector as a duration array at the five minute intervals; datetime can't have time fields alone; they must include a reference date. Can deal with, but for this purpose the duration is simpler.
datenum and datetick can be made to work but is simply too klunky to even consider over builtin newer time classes; plot is now duration and datetime aware so will get the desired scaling automagically.

Más respuestas (0)

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by