How to vectorize histogram of rows in a matrix?
2 views (last 30 days)
Show older comments
Is there any way to vectorize the following where it doesn't use the for loop?
rows = 5;
cols = 20;
z = randn(rows, cols);
for i = 1:size(z,1)
figure;
histogram(z(i,:))
title(['Histogram of row ',num2str(i)]);
xlabel('Bins');
ylabel('Frequency');
end
1 Comment
Ameer Hamza
on 27 Oct 2020
This is probably the fastest way. Any other method will likely make it slower and more complicated.
Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!