Dear all, The idea was to add ticks label to the x axis with a predefined label. The vector label was a mix of empty cell (i.e. []_ and char (e.g., BL 1, BL 2, SS2 2, SS2 3). However, when plot, there was no tick being displayed. I really appreciate if someone can point what mistake that I have overlooked. The complete code and mat file is attached together with thread to make the discussion easier.
Thanks in advance for any suggestion
load('prob_xtickLable.mat');LimitRange=14401:27301;Xaxis_time= [273.5 275.5 277.5 279.5 281.5 283.5 303.5 305.5 307.5 315.5 ... 317.5 319.5 327.5 329.5 331.5 339.5 341.5 343.5 351.5 353.5 ... 355.5 363.5 365.5 367.5 375.5 377.5 379.5 387.5 389.5 391.5]; XLabel=XLabel;Vector_res1=NaN(length(time_hour),1); % Prelocate with NaN
Vector_res2=NaN(length(time_hour),1); % Prelocate with NaNVector_label_Xaxis=num2cell(NaN(length(time_hour),1));Vector_res1(ismember(time_hour,Xaxis_time))=mean_kss;Vector_res2(ismember(time_hour,Xaxis_time))=SD_kss;%%Replace NaN with [].while other cell contained the appropriate label. The use
% of [] to ensure matlab ignore the no label row.
Vector_label_Xaxis = repmat({[]},[(length(time_hour)) 1]);Vector_label_Xaxis(ismember(time_hour,Xaxis_time))=XLabel; yyaxis righterrorbar(time_hour(:), Vector_res1(:), Vector_res2(:), '--x','MarkerSize',15)hold onyyaxis leftplot(time_hour(:),SleepDrive)%%Problem: No tick being displayed
xticklabels(Vector_label_Xaxis)
Best Answer