Create 58 graphs as a waterfall plot from 58 .csv files

14 views (last 30 days)
I have a folder with 58 .csv files. Each .csv file has 415 rows and 2 columns. My intention is to import these files one by one generating a numeric 415 x 2 matrix. The first column represents the x-axis and the second column the y-axis. I'm able to plot these graphs one by one overlaying each other (using the code below) but I want to plot these graphs as a waterfall plot. However, despite many tries, I'm not able to achieve this. Could anybody help?
This is the current script:
addpath('C:\Users\3826740\Dropbox\Personal Storage\Documents\Scheikunde\Master\Masters Research\Data\Raw Data\FTIR\170927\hydration exp\Spectracsvfiles')
dirData = dir('C:\Users\3826740\Dropbox\Personal Storage\Documents\Scheikunde\Master\Masters Research\Data\Raw Data\FTIR\170927\hydration exp\Spectracsvfiles\*.csv')
ColorSet = varycolor(58);
set(gca, 'ColorOrder', ColorSet, 'xdir', 'reverse');
hold all;
for i = 1:size(dirData,1)
A = importfile1(dirData(i).name, 3, 417);
x = A(:,1);
y = A(:,2);
plot(x,y);
end
set(gcf, 'Colormap', ColorSet);
colorbar
ylim([1.4 3.4])
caxis([0 60])
xlabel('Wavenumbers (cm^{-1})')
ylabel('Absorbance')
This generates an 'overlay' plot as displayed below,
but I want it looking like the waterfall plot as displayed below.
  1 Comment
Jan
Jan on 2 Oct 2017
Note: There is no need to add a folder to Matlab's PATH if you only want to read files from it. Better do not touch Matlab's PATH without a need to do so.

Sign in to comment.

Accepted Answer

OCDER
OCDER on 2 Oct 2017
You should use plot3 instead of plot to draw line in 3D. More info here:
Try this example and adjust this to fit your purpose:
t = 0:0.5:20;
clr = jet;
hold all
for j = 1:10
plot3(t, j*ones(size(t)), sin(t), 'color', clr(5*j, :)); %plot lines in 3D
end
view(gca, [10, 45, 45]) %play around with this view

More Answers (1)

Steven Lord
Steven Lord on 2 Oct 2017
Stack the individual data variables into one matrix then call the waterfall function in MATLAB.

Community Treasure Hunt

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

Start Hunting!