MATLAB Answers

How to merge several 2D plots and make a single 3D plot if vector lengths are not same.

43 views (last 30 days)
I am trying to plot a 3D plot. for which I want to combine 20 2D plots(20 because I need >15 only for my work).
for 2D plots for these 20 different instances I have created two 20X5 matrix( tau and a ).where each row of tau contains value of X axis and each row of a contains particular Y axis value.
Now for 2D plots I can easily get plot by plot(tau(i,:),a(i,:)) ,where i can be anything between 1 to 20.but what to do if I want all these 2d plots arranged one by one from i=1 to 20. Plotting 3D as surface would be good.
I tried other commands given in other answers but I did not get my desired plot because in most of the cases commands require X,Y,Z to be vectors of same length. but in my problem vector lengths are not same.
please provide suggestions and command , how to solve this issue.

0 Comments

Sign in to comment.

Answers (1)

Cameron B on 18 Jan 2020
Can you provide some of your data? That way, we could get a better idea of the min/max values for x and y and determine if interpolation or something similar could help.

1 Comment

ASHU DAYAL CHAURASIYA on 19 Jan 2020
I am having tau matrix as follows
tau(1,:) = [1.50,2.53,2.76,3.79,4.25]
tau(2,:)=[1.56 2.85, 3.12,4.20,4.35]
....
....
and as we keep going till row 20 column values will keep increasing a little bit and has no boundation on range.
similarly for a values
a(1,:)=[0.30,0.17,0.23,0.45,0.39]
....
....
and in every row till row 20 these column values will vary randomly between 0.10 to 0.50.
now for normal 2D plot I was using command plot(tau(i,:),a(i,:)) , where i is the desired row I want to take for print and I can get easily 20 2D plots by varying i from 1 to 20. but what to do if I want these 20 2D plots arranged to form a 3D plot/surface.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!