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

12 次查看(过去 30 天)
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 个评论
Jan
Jan 2017-10-2
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.

请先登录,再进行评论。

采纳的回答

OCDER
OCDER 2017-10-2
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

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by