matlab - Make multiple histograms for each column in matrix -


i loop through each column in 306x20 matrix, nan values filling in empty spaces, , create histogram each row (finish 20 histograms). best way this? pseudocode implement:

for = 1:(number of columns)      % loop through each column generate different histogram same      % x , y labels , title      % hist(data, 20) end 

thank you

i assume want separate figure each histogram. can achieved for-loop , figure-statement open new figure in each iteration. in matlab version r2014b , above, use histogram-function plot histogram, in versions below r2014b use hist instead (hist still works in r2014b , above). both functions ignore nan-values in dataset.

% generate random data nan-values x = randn(306,20); = randi(5,[306,20]); x(a==3) = nan;  % plot histograms = 1:size(x,2)     figure;     histogram(x(:,i)) % before r2014b use "hist" instead     title(['histogram of row ',num2str(i)]);     xlabel('bins');     ylabel('frequency'); end 

this gives following result last row: result


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -