plotting a surface between two curve
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Paul
el 9 de Abr. de 2023
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!