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

조회 수: 7 (최근 30일)
Ewout van der Feltz
Ewout van der Feltz 2017년 10월 2일
댓글: OCDER 2017년 10월 2일
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
  댓글 수: 2
Ewout van der Feltz
Ewout van der Feltz 2017년 10월 2일
This has worked very well, thanks a lot!
OCDER
OCDER 2017년 10월 2일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (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