フィルターのクリア

plot binary data over time to specific conditions

3 ビュー (過去 30 日間)
Phil K
Phil K 2024 年 2 月 20 日
コメント済み: Voss 2024 年 2 月 22 日
Hi there,
I have some log data of a battery pack and its processor. The processor gives me some binary data (is a condition TRUE) in form of a cell.
The first row represents the condition and each row after the first represents one log tick where I also have an "elapsedTime" vector containing the time i.e. the total log ticks are 19764, so also the elapsedTime vector is 19764x1.
Now I want to plot this battstatvector where on the y-axis I have my conditions (OCA, TCA, RSVD, etc.) and on the x-axis I want to plot the corresponding binary data over the elapsedTime.
All in all I want to plot something like this
where each 1 represents a dark color and a 0 represents a lighter color. Is this even possible in Matlab?
Best,
Philipp

採用された回答

Voss
Voss 2024 年 2 月 20 日
編集済み: Voss 2024 年 2 月 20 日
load('battstatvector.mat') % a mat file containing a cell array like yours
battstatvector
battstatvector = 835×11 cell array
{'OCA'} {'TCA'} {'RSVD'} {'OTA'} {'RCA'} {'RSVD'} {'TDA'} {'OTA'} {'RSVD'} {'TCA'} {'OCA'} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 1]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]} {[ 0]}
figure('Position',[10 10 800 200])
names = battstatvector(1,:);
data = cell2mat(battstatvector(2:end,:).');
im = image(data,'CDataMapping','scaled');
clim([0 1]);
light_blue = [171 185 212]/255;
dark_blue = [37 66 108]/255;
colormap([light_blue; dark_blue])
xticks([])
yticks([])
n = size(data,1);
text(ones(1,n),1:n,names,'Color','w','FontWeight','bold')
  2 件のコメント
Phil K
Phil K 2024 年 2 月 22 日
Thank you very much, I appreciate your solution and it works perfectly!!
Voss
Voss 2024 年 2 月 22 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by