Shape Interpolation from csv

11 ビュー (過去 30 日間)
Sam Hill
Sam Hill 2020 年 8 月 21 日
編集済み: Stephan 2020 年 8 月 21 日
I have a shapes in terms of cartesian coordinates read from a csv file and want to interpolate the shape to increase the number of points I have. CSV has three columns (X, Y, Z) and each row is on point. All the documentation I have found (meshgrid, datagrid, ect) works by using vectors to create a grid of points, I already have the points but matlab will not let me manipulate the data while in 'double' format. How can I read in the data and interpolate the points to increae the density of my meshes?
%Read in file data
a=csvread('r1.csv');
%convert m to mm
X=a(:,1)/1000;
Y=a(:,2)/1000;
Z=a(:,3)/1000;
Then I want to interpolate between data points to increase the number of points I have.
Any help will be greatly appreciated.

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 8 月 21 日
File Exchange, John D'Errico, "interparc"
  1 件のコメント
Sam Hill
Sam Hill 2020 年 8 月 21 日
a=csvread('r1.csv')
a1=a(:,1)/1000;
a2=a(:,2)/1000;
a3=a(:,3)/1000;
ra=interparc(0.5, a1, a2, a3)
returns the error:
Error using chckxy (line 50)
The first input must contain unique values.
Error in spline (line 72)
[x,y,sizey,endslopes] = chckxy(x,y);
Error in interparc (line 316)
spl{i} = spline(cumarc,pxy(:,i));

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


Stephan
Stephan 2020 年 8 月 21 日
編集済み: Stephan 2020 年 8 月 21 日
If the curvature is small enough compared to the distance between the original points, a little bit of analytical geometry might help:
% Some data to play with - an arbitrary line in 3D
x = [1 2 3 4];
y = [-1 5 2 7];
z = [0 1 2 6];
% Concatenate vectors of x, y, z to one matrix
A = [x; y; z];
% Calculate Coordinates of the bisector to get query points
B = (A(:,1:end-1) + A(:,2:end)) ./ 2;
% Extract the single vectors
xq = B(1,:);
yq = B(2,:);
zq = B(3,:);
% plot the line that connects all original points
plot3(x,y,z)
hold on
% plot the original points in blue
scatter3(x,y,z,'ob','filled')
% plot the new interpolated points in red
scatter3(xq,yq,zq,'or','filled')
hold off
You could repeat this process (for example by using a function) if you need more points.

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by