interpolation of the x y z coordinates with color to create a cube

5 views (last 30 days)
Hello everyone,
Can somebody help to interpolate the data to create a 3d cube. currently i have a following code, but it does not create the cube. Actually i need to interpolate the colors(given us number 1 to 6)on the other points of cube. I have attached the txt.
clc;
clear;
format compact;
level = readmatrix("Coordinates.txt", "NumHeaderLines",6, "ExpectedNumVariables",4);
x = level(:,1); %size: (275,1)
y = level(:,2); %size: (275,1)
z = level(:,3); %size: (275,1)
c = level(:,4); %size: (275,1)
xv = linspace(min(level(:,1)), max(level(:,1)), 275); %size: (1,275)
yv = linspace(min(level(:,2)), max(level(:,2)), 275); %size: (1,275)
[X,Y] = meshgrid(xv, yv); % X size: (275,275) and Y size: (275,275)
Z = griddata(x,y,z,X,Y); %size: Z (275,275)
C = griddata(x,y,z,c,X,Y,Z,'nearest');
hold on
surf(X, Y, Z,'cdata',C); %
grid on
shading interp
axis equal
colorbar
colormap(hsv(6));
Thank you in advance.
  2 Comments
KSSV
KSSV on 27 Aug 2020
You cannot do interpolation to get a cube. What exactly you want?
Kamilya Omirzhankyzy
Kamilya Omirzhankyzy on 28 Aug 2020
i want to get a 3d cubic model of the provided data. The first 3 columns are coordinates for each color that are indicated in the 4th column.

Sign in to comment.

Answers (0)

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!