Intersection between spline and a line

11 次查看(过去 30 天)
I used a cscvn spline to obtain the following using fnplt:
I'm having trouble using this data which is held in a struct with form : 'pp' to find the intersection points with other functions. I would eventually want to find the intersection of this spline and circles however if anyone could show me the method of find the POI with the line 'y=x' I'd be grateful.
I've read through this document and various other threads however I couldn't implement it for my own data.
I've attached the struct (data) to this post.

回答(1 个)

Christiaan
Christiaan 2015-3-23
Dear Brian,
The abbreviation pp means that the polynomial that is defined, is a piecewise polynomial. In the structure you can find 'the order' (at your file it is four) that tells you the number of coefficients used for each polynomial. The 'pieces' tells you how many polylines are used in the plot. (in your data the order is 17). For each polynomial the breaks are used to define the start and end points of each polynomial. The break is therefore an array of 17+1 inputs.
If you now like to know where your polyline intersects the line y=x, you could use this code:
clc;clear all;close all;
test=load('test');
fnplt(test.test); grid on;hold on;
x=linspace(0,150,1000);y=x;
plot(x,y); hold on;
mycv = fnbrk(test.test,[1 200]);
cuts = fnval(mycv, mean(fnzeros(fncmb(fncmb(mycv,[0,200]),'-',fncmb(mycv,[200,0])))));
intersection = [cuts(1,1) cuts(2,1)];
plot(intersection(1),intersection(2),'go');
Good luck! Christiaan

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by