Intersection between spline and a line

3 views (last 30 days)
Brian Vu
Brian Vu on 21 Mar 2015
Answered: Christiaan on 23 Mar 2015
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.

Answers (1)

Christiaan on 23 Mar 2015
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;
fnplt(test.test); grid on;hold on;
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)];
Good luck! Christiaan

Community Treasure Hunt

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

Start Hunting!