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

조회 수: 1 (최근 30일)
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

채택된 답변

dpb
dpb 2022년 6월 8일
편집: dpb 2022년 6월 8일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by