fit curve with parameter
Show older comments
I have some points, annotated from an xray, along the spine. I need to fit a curve through these points. After that, i want to parametrize my fitted curve from 0 to 1, so i can move along the curve in equal intervals. If i just project my points onto the x axis, my line will be distorted.
So i want to choose point 0, which should give me the x/y coordinates of the fitted curve and the slope of the curve at this point. Point 0.5 should give me the point in the middle of the curve and its x/y values and the slope there, and point 1 the last point of the curve.
Any ideas how to do this? I thought about spline/cscvn, but i don't really get it...
3 Comments
Rik
on 19 Oct 2020
You could simply not tell Matlab that the two curves you're fitting are (t,x) and (t,y).
Stefan Lang
on 19 Oct 2020
Rik
on 19 Oct 2020
E.g. this:
a=linspace(0,pi,100);x=5*sin(a)+rand(size(a));y=6*cos(a)+rand(size(a));%replace with your data
subplot(1,2,1)
plot(x,y)
title('actual data')
subplot(1,2,2)
t=linspace(0,1,numel(x));
plot(t,x),hold on,plot(t,y),hold off
title('as a function of t')
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!