Hi Bowen,
To extract a specific number of uniformly spaced points from a B-spline curve generated by MATLAB's spmak and fnplt functions, you can follow these steps:
% Example control points and knots (replace with your data)
controlPoints = [0 1 2 3 4 5; 0 1 0 -1 0 1]; % Example 2D control points
knots = [0 0 0 1 2 3 4 4 4]; % Example knots
% Create B-spline using spmak
sp = spmak(knots, controlPoints);
% Evaluate the B-spline curve using fnplt
% Get points of the B-spline curve
[x, y] = fnplt(sp, [knots(3), knots(13)]);
% Total number of points generated by fnplt
numPoints = length(x);
% Desired number of uniformly spaced points
desiredPoints = 60;
% Generate indices for uniformly spaced points
uniformIndices = round(linspace(1, numPoints, desiredPoints));
% Select uniformly spaced points
uniformX = x(uniformIndices);
uniformY = y(uniformIndices);
% Plot the results
figure;
plot(x, y, 'r-', 'DisplayName', 'B-spline Curve');
hold on;
plot(controlPoints(1, :), controlPoints(2, :), 'ko', 'DisplayName', 'Control Points');
plot(uniformX, uniformY, 'bo', 'DisplayName', 'Uniform Points');
legend;
title('B-spline Curve with Uniformly Spaced Points');
xlabel('X');
ylabel('Y');

