Borrar filtros
Borrar filtros

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

32 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Voss
Voss el 20 de Mzo. de 2022
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 comentario
ans
ans el 20 de Mzo. de 2022
Editada: ans el 20 de Mzo. de 2022
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by