Shape Interpolation from csv
16 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Stephan
on 21 Aug 2020
Edited: Stephan
on 21 Aug 2020
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.
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!