plotting a surface between two curve
8 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have plotted two curves by importing data. The first curve, referred to as the small curve, consists of the points (x1, y1, z1), while the second curve, the large curve, is composed of the points (x2, y2, z2), as illustrated in the figure.
To create these curves, I imported the data from the attached small.txt and large.txt files. However, as I did not require the first columns of the data, and they needed to be fixed values (0.1577 and 0.1590, respectively), I utilized the following code:
Small curve:
aa1 = readtable(file_address);
n=size(aa1.Var1,1);
x1=ones([n,1])*0.1577;
y1=aa1.Var3;
z1=aa1.Var2;
ff=figure(11);
plot3(x1,y1,z1)
Large curve
aa2 = readtable(file_address);
n=size(aa2.Var1,1);
x2=ones([n,1])*0.1590;
y2=aa2.Var3;
z2=aa2.Var2;
ff=figure(11);
plot3(x2,y2,z2);
I am interested in connecting these two curves together using a surface that takes on the shape of a cone, similar to the one shown in the second picture. Can you please guide me on how to accomplish this?
Thank you in advance for any assistance you can provide.
采纳的回答
Paul
2023-4-9
Hi M,
Here's some code to get started.
% small curve
file_address = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1350204/small.txt';
aa1 = readtable(file_address);
n=size(aa1.Var1,1);
x1=ones([n,1])*0.1577;
y1=aa1.Var3;
z1=aa1.Var2;
%Large curve
file_address = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1350209/large.txt';
aa2 = readtable(file_address);
n=size(aa2.Var1,1);
x2=ones([n,1])*0.1590;
y2=aa2.Var3;
z2=aa2.Var2;
figure;
hold on
plot3(x1,y1,z1)
plot3(x2,y2,z2);
surf([x1 , x2].', [y1 , y2].' , [z1 , z2].','FaceColor','r','EdgeColor','none')
view(3)
Play around with the number of points used in the surf and the surface properties and the view to get the results you want.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!