Hello! How can I draw a perpendicular line to another? I have the line it has to intersect defined by the following code:
% Get a known index. "known" because it's one of the training points. knownIndex = randperm(length(x), 1)
% Get a unknown index. "unknown" because it's one of the interpolated points. unknownIndex = randperm(length(finerSpacing), 1)
% Get the x,y coordinates for these indexes.
xKnown = knots(1, knownIndex) yKnown = knots(2, knownIndex) xUnknown = splineXY(1, unknownIndex) yUnknown = splineXY(2, unknownIndex) % Now draw a line between them in dark green.
darkGreen = [0, 0.5, 0]; plot([xKnown, xUnknown], [yKnown, yUnknown], 'o-', ... 'Color', darkGreen, 'MarkerSize', 24, 'LineWidth', 3); legend('Knots', 'Spline', 'Line between random knot and random point');
The problem is that I can not make it so that the new line is perpendicular on the "known index". What can i do? Please help!
Best Answer