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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by