3D or stack plot of 2D xy data
Show older comments
Dear All,
I have searched and I know this question has been addressed partially by many posts on this forum, but I still cannot figure out how to make a 3D plot from a series of 2D data files.
Here is what I've done so far: 1. import the 180 data files (in this case) into matlab. The data files consist of numbers in CSV format, specifically wavenumbers vs. intensity. I imported the data using the routine below from as suggested by others:
csvFiles = dir('*.csv');
numfiles = length(csvFiles);
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = importdata(csvFiles(k).name);
end
After doing that, I get a single variable called "mydata" which is a 1x180 cell array. Inside the cell array is a single row of and 180 columns. Every cell in the cell-array (for exmaple row 1 column 1) has all the XY data as a double, so cell 1:1 shows x 2 double.
2. now I want to plot that, sounds simple...Each column cell contains all the XY data for the infarred spectrum, and there are 180 columns
so why can't I plot each pattern for each column, where the column number offsets each spectrum by 1 unit? I can plot the "mydata" 1x180 cell-array as a streamline graph, but that just overlaps all the data on a 2D plot.
What I would like to do is somehow add a Z direction, starting from some value Z1 and Z180, or some other values so the plot looks nice. But how? Using the column number as Z would be great, but I can't figure out how to do that.
I'm sorry if this has been addressed elsewhere, but I couldn't find the post.
I've also tried the uigetfile command as well:
[filenames, pathname] = uigetfile('MultiSelect', 'on');
filenames = cellstr(filenames); % EDITED
for n = 1:length(filenames)
afile = fullfile(pathname, filenames{n}); % EDITED
data = importdata(afile);
% Remove the file extension file the name:
[dummy, afilename] = fileparts(filenames{n});
save(afilename, 'data');
end
But all I get is a bunch of MAT files, but I can't figure out what I can do with them.
If you have any suggestions I would most appreciate it!
Best J
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!