Advertisement
ykamer

Untitled

Mar 21st, 2021
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.21 KB | None | 0 0
  1. %0= aktif
  2. %1= uyanik
  3. %2= uyku
  4.        
  5.         %Baslangic saati    %Bitis saati     %Kod
  6. cell_in ={
  7.         '2021-03-21 07:00', '2021-03-21 10:15', 0
  8.         '2021-03-21 10:15', '2021-03-21 10:30', 1
  9.         '2021-03-21 10:30', '2021-03-21 12:00', 2
  10.         '2021-03-21 12:00', '2021-03-21 15:00', 0
  11.         '2021-03-21 15:00', '2021-03-21 15:10', 1
  12.         '2021-03-21 15:10', '2021-03-21 16:15', 2
  13.         '2021-03-21 16:15', '2021-03-21 20:00', 0
  14.         '2021-03-21 20:00', '2021-03-21 21:45', 1
  15.         '2021-03-21 21:45', '2021-03-22 01:20', 2
  16.         '2021-03-22 01:20', '2021-03-22 03:00', 1
  17.         '2021-03-22 03:00', '2021-03-22 07:00', 2
  18.         %%
  19.         '2021-03-22 07:00', '2021-03-22 10:15', 0
  20.         '2021-03-22 10:15', '2021-03-22 10:30', 1
  21.         '2021-03-22 10:30', '2021-03-22 12:00', 2
  22.         '2021-03-22 12:00', '2021-03-22 15:00', 0
  23.         '2021-03-22 15:00', '2021-03-22 15:10', 1
  24.         '2021-03-22 15:10', '2021-03-22 16:15', 2
  25.         '2021-03-22 16:15', '2021-03-22 20:00', 0
  26.         '2021-03-22 20:00', '2021-03-22 21:45', 1
  27.         '2021-03-22 21:45', '2021-03-23 01:20', 2
  28.         '2021-03-23 01:20', '2021-03-23 03:00', 1
  29.         '2021-03-23 03:00', '2021-03-23 07:00', 2
  30.         };
  31.  
  32. mat_in      = nan(size(cell_in));
  33. mat_in(:,1) = datenum(cell_in(:,1),'yyyy-mm-dd HH:MM');
  34. mat_in(:,2) = datenum(cell_in(:,2),'yyyy-mm-dd HH:MM');
  35. mat_in(:,3) = cell2mat(cell_in(:,3));
  36.  
  37. mat_in  = sortrows(mat_in,1);
  38. mat_in(:,1:2) = mat_in(:,1:2)-7/24;
  39. MIN_DT  = floor(min(mat_in(:,1)));
  40. MAX_DT  = floor(max(mat_in(:,1)));
  41.  
  42. TIME_smp    = 1; %in minutes
  43. timeVec     = 0:TIME_smp/(24*60):1;
  44. dtVec       = MIN_DT:MAX_DT;
  45. N_t         = numel(timeVec);
  46. N_d         = numel(dtVec);
  47. checkMat    = nan(N_d,N_t);
  48.  
  49. [ir,ic] = ind2sub([N_d N_t],find(isnan(checkMat)));
  50. linT    = dtVec(ir) + timeVec(ic) ;
  51. for i=1:size(mat_in,1)
  52.     idSel = linT>mat_in(i,1) & linT<mat_in(i,2);
  53.     checkMat(idSel) = mat_in(i,3);
  54. end
  55. figure;
  56. imagesc(checkMat);
  57. %set(gca,'yticklabel',{'12 araliik',' bok',})
  58. set(gca,'ytick',[1 2]);
  59. set(gca,'xtick',[0:24]*60/TIME_smp + TIME_smp)
  60. set(gca,'xticklabel',[0:24])
  61. set(gca,'xticklabel',[7:24 0:6])
  62. colormap([1 0 0; 0 0 1; 0 1 0;]);
  63. pbaspect([6 1 1]);
  64. colorbar;
  65. grid on;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement