Dont know what Polyval is here doing :-/
Show older comments
Hello Together, i dont know what polyval is doing here with the blue lines:
What i want is a line through all points (like the black one).

Code for it is at end.
- As you can see, the black line with polyval is plotted correct.
- The points yd1 for xd1 and yd2 for xd2 are plotted correct
- What is not plotted correct, is the polyval for xd1 and xd2 -> What have i done wrong here?
Thanks a lot!
%Black line
xml1 = [ -0.3, 0.4];
yml1 = [-0.15, -0.15];
xml2 = 0.4 + 0.7 * cos(0:pi/50:pi/2) ;
yml2 = -0.85 +0.7 * sin(0:pi/50:pi/2);
xml3 = [1.1, 1.1];
yml3 = [-0.85, -1.15];
load ('xdata310519.mat')
%xd1 = 0 0.3906 0.7430 1.0227 1.2022 1.2641 1.2022
%yd1 = 0 -0.0619 -0.2414 -0.5211 -0.8735 -1.2641 -1.6547
%xd2 = 0 0.1943 0.3696 0.5087 0.5980 0.6288 0.5980
%yd2 = 0 -0.0308 -0.1201 -0.2592 -0.4345 -0.6288 -0.8231
grad = 5;
p1 = polyfit( xd1, yd1, grad);
p2 = polyfit( xd1, yd2, grad);
f1 = polyval( p1, xd1);
f2 = polyval( p2, xd2);
hold on
%Black line
plot(xml1, yml1, '--k');
plot(xml2, yml2,'--k');
plot(xml3, yml3, '--k');
%points
plot(xd1, yd1,'s', xd2, yd2,'s');
plot(xd1, f1,'b', xd2, f2,'b');
Accepted Answer
More Answers (0)
Categories
Find more on Spline Postprocessing 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!


