problems plotting multiple 2D curves in 3D
1 view (last 30 days)
Show older comments
I have 70 (x,y) data curves which i would like to plot in 3D. the x axis is the same for all 70 data sets, it is only y that changes from data set to data set.
so what i would like to do is assign z = 1 for the first curve, z = 2 for the second curve ects.
the code is shown below. i will gladly post the "readSWING" code if it relevant
% Load the data into matlab using "readSWING"
for n = 0:69
eval(['s' num2str(n) ' = readSWING(''C:\path\sample_rad' num2str(n) '.dat'');']) % frame "n" is read into "sn"
% plot the data in 3D
figure(1)
set(gca,'xscale','lin')
set(gca,'yscale','log')
set(gca,'zscale','lin')
hold on
set(gca,'fontsize',16)
set(gca,'linewidth',1.3)
xlabel('Q (Å^{-1})','fontsize',16)
ylabel('Detector counts in 1 sec.','fontsize',16)
eval(['plot3(s' num2str(n) '(:,1),s' num2str(n) '(:,2),repmat(n,1111),''Color'',[1 0 ' num2str(n) '/70*1],''linewidth'',1.5)'])
hold on
end
EDIT: the code runs very slow. i typically abort it by ctrl+c after a few curves
When i run the script i just get a normal 2D whit all the curves superimposed. My attempt is based on the solution to a similar problem given here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/299404 where following code works
plot3(x1, y1, repmat(z1,size(x1)))
hold on
plot3(x2, y2, repmat(z2,size(x2)))
plot3(x3, y3, repmat(z3,size(x3)))
and so on.
size(x) is always 1111 as the x-axis is the same for all 70 curves. i use repmat((n+1),1111) because n goes from 0 to 69. this is because the files are named "data_0" to "data_69". it is not as important as being able to plot in 3D so i can remove that if it cause problems. this is of course also the case for the coloring.
i currently use matlab R2011b but i believe my university has license for the newest version as well. so i can upgrade if relevant
0 Comments
Answers (1)
See Also
Categories
Find more on Interactive Control and Callbacks 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!