Intersection between spline and a line
12 views (last 30 days)
Show older comments
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.
0 Comments
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;
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
0 Comments
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!