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.
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!