bar graph of separate columns from different data sets

Hello everyone! I have this problem, I need to upload data from 3 different files and create a single bar for all. What I have got so far is:
path='C:\nath\bars';
eval(['load ' path '\bar1.mat']);
figure
figure1=bar(dist, 'histc');
set(figure1,'FaceColor','g')
hold all
eval(['load ' path '\bar2.mat']);
figure2=bar(dist, 'histc');
set(figure2,'FaceColor','r')
hold all
eval(['load ' path '\bar3.mat']);
figure3=bar(dist, 'histc');
set(figure3,'FaceColor','b')
That gives me a graph where the columns overlap. Is it possible to separate them so that for each bin I have 3 different columns?
Thank you in advance!

Réponses (1)

Attach a screenshot so we can see what you're talking about. While you're at it, attach your .mat files also. And change this
path='C:\nath\bars';
eval(['load ' path '\bar3.mat']);
to this
folder ='C:\nath\bars';
fullFileName = fullfile(folder, '\bar3.mat');
load(fullFileName);
path is a reserved word in the MATLAB language so you don't want to redefine it.

1 commentaire

thank you for your answer! and you are right! so this is how it looks like:
and I want for example for the bin 0-3.5 to have 3 different columns.
Then I followed your advice and did
folder ='C:\nath\bars';
fullFileName = dir(fullfile(folder, '*.mat'));
so that it loads all files
and did a loop for f = 1:length(fullFileName) create the graph but again I dont know what to do after!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Question posée :

le 26 Juin 2014

Commenté :

le 27 Juin 2014

Community Treasure Hunt

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

Start Hunting!

Translated by