Interpolate surface between 3D lines

Hi all,
i have several 3D lines and i want to use them to create a surface between them.
In the image above you can see two of those lines as an example. The data used for those lines is in the attachment. Below you see the code i tried to use to create a surface between these two lines.
Unfortunately, it also created a surface between each of the lines itself.
Is there a way to create a surface just for the area between the two lines?
Thanks a lot !
y = [Data1(:,1); Data2(:,1)];
x = [Data1(:,2); Data2(:,2)];
z = [Data1(:,3); Data2(:,3)];
figure;
rangeX = -1500:10:0;
rangeY = 0:0.1:20;
[X,Y] = meshgrid(rangeX,rangeY);
Z=griddata(x,y,z,X,Y,'cubic');
surf(X,Y,Z)
hold on;
plot3(Data1(:,2),Data1(:,1),Data1(:,3),'LineWidth',2);
plot3(Data2(:,2),Data2(:,1),Data2(:,3),'LineWidth',2);
grid on

 採用された回答

Mohammad Hukan
Mohammad Hukan 2018 年 8 月 20 日
編集済み: Mohammad Hukan 2018 年 8 月 20 日

0 投票

If I understood what you are looking for then I would recommend trying 'fit' function. I think it would work
https://www.mathworks.com/help/curvefit/fit.html

8 件のコメント

Lars Gode
Lars Gode 2018 年 8 月 29 日
Thanks for the answer and sorry for the late response. Unfortunately, the 'fit' function is also not solving the problem completely.
I now have a pretty good surface between the two lines but there is still the problem with the surface between the lines itself.
Mohammad Hukan
Mohammad Hukan 2018 年 8 月 29 日
can you maybe uplode the plot as a .fig? I can't really see it clearly from just the picture :)
Lars Gode
Lars Gode 2018 年 8 月 29 日
sure, here you go :)
Mohammad Hukan
Mohammad Hukan 2018 年 8 月 29 日
ok I'm still not sure what exactly are you looking for! do you mean you just want the surface to be between the two lines and not extending beyond that (as it is happening in the plot you attached)?
Lars Gode
Lars Gode 2018 年 8 月 30 日
Yes exactly, the surface is only supposed to be inbetween the area of both lines.
So basically, the black marked areas should not be there. I hope you understand now what I mean :)
Mohammad Hukan
Mohammad Hukan 2018 年 8 月 30 日
編集済み: Mohammad Hukan 2018 年 8 月 30 日
ok yes now I get it. well unfortunately I don't know of a direct answer but what you could do is define data points (x,y) between the two lines and evaluate z using the fit that you generated and then plot the data (including you original data) manually. I think this way you will give you what you are looking for. Good luck :)
Lars Gode
Lars Gode 2018 年 8 月 30 日
Allright thank you very much! The fit function was a good help to use as a basis for further coding.
Sanoop Siby
Sanoop Siby 2020 年 3 月 5 日
Lars Gode, Did you happen to find a solution to your question. Please post it if so. Thanks in advance.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by