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

2 visualizaciones (últimos 30 días)
Ewout van der Feltz
Ewout van der Feltz el 2 de Oct. de 2017
Comentada: OCDER el 2 de Oct. de 2017
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 comentario
Jan
Jan el 2 de Oct. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

OCDER
OCDER el 2 de Oct. de 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
  2 comentarios
Ewout van der Feltz
Ewout van der Feltz el 2 de Oct. de 2017
This has worked very well, thanks a lot!
OCDER
OCDER el 2 de Oct. de 2017
You're welcome!

Iniciar sesión para comentar.

Más respuestas (1)

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

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by