How do I plot multiple XY vectors with corresponding Z values on the same plot?
이전 댓글 표시
Hello,
I have recently just started my matlab experience, and have run into a situation that I am having a hard time solving. I have an xls file with with 25 columns (the first on being the X values, and the corresponding 24 being the Y values). I would like to plot the individual 24 XY vectors on the same plot but add a Z element to make it "3D". I can easily plot them all on one graph in 2D, but I'm having trouble figuring out how to add the Z axis in. Here is the code that I am using so far:
%
% clear all
clear all
%%Location of data to analyze
fname='All B columns ROI 94.xls'
%%open data
data=xlsread(fname);
s=size(data);
col=2:s(2)
colA=data(:,1);
X=colA;
Y=data(:,col);
Z=(length(col)); %%I'm assuming this is the problem as it isn't a matrix
figure;
hold on;
plot3(X,Y,Z);
I'm uncertain as to whether I need to recreate the XYZ data into a 3D matrix and then plot it, or if there is a much simpler way of plotting this. I've attached a figure from excel that I was able to make that demonstrates what I would like the plot to look like (it only contains the first three columns of data as an example).

I've done multiple searches and haven't been able to find a solution, so I thought that I'd ask. Any help would be greatly appreciated!
Thanks, Russ
채택된 답변
추가 답변 (1개)
Joseph Cheng
2014년 6월 16일
Here is what you can do to get something along those lines. I'm not sure if there is a function to plot that however what you can do is draw polygons based on the data. See my example:
Y = randi(50,4,100);
X = 1:100;
x = [X X(end:-1:1)];
y = [Y zeros(size(Y))];
z = ones(size(x));
fill3(x,z,y(1,:),'r',x,2*z,y(2,:),'g',x,4*z,y(3,:),'b');axis equal; legend
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!