How to plot histogram of each column of table and compare against the column of another table using for loop?

18 ビュー (過去 30 日間)
I have 2 tables with the same size (644X4). One is a old result and the latter is a new result. What I want to do is that I want to compare the result of each column of these two tables by plotting histogram using "for-loop". Eventually, I want to get four seperate histograms dipicting the comparison of old result and new result for each column.

採用された回答

Voss
Voss 2022 年 3 月 20 日
It's not clear exactly what you mean by "depicting the comparison". Should it be two histograms per table column, one histogram for the old table and one for the new? Or maybe one histogram per column, showing the difference between old and new?
In any case, here is some code that can maybe serve as a starting point, which you can adapt as needed:
% creating some random tables first:
data_old = num2cell(randn(644,4),1);
t_old = table(data_old{:});
data_new = num2cell(randn(644,4),1);
t_new = table(data_new{:});
% (1) two separate histograms for each column of the tables:
figure();
for ii = 1:4
subplot(2,2,ii);
histogram(t_old{:,ii});
hold on
histogram(t_new{:,ii});
end
% (2) one histogram per column, showing the (absolute) differences:
figure();
for ii = 1:4
subplot(2,2,ii);
histogram(abs(t_old{:,ii}-t_new{:,ii}));
end
  1 件のコメント
ans
ans 2022 年 3 月 20 日
編集済み: ans 2022 年 3 月 20 日
Thank you so much for your quick response. I am sorry for the way I post my question if you feel somehow confused. I acctually mean one histogram per column, showing the difference between old and new result of two tables.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by