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!