Closed spline fit of airfoil coordinates

11 Ansichten (letzte 30 Tage)
andrea84
andrea84 am 25 Okt. 2012
Beantwortet: Unai San Miguel am 15 Mär. 2017
Hi, I'm working on airfoil coordinates and trying to fit the data point to a single closed curve but now i need some help to extract the coordinate of some point lying on the curve and but the result using fnval (the coordinates of the green point are named "pin") is clarly wrong. How could I fix it? Here's my code:
coord=load('S823.txt'); x=coord(:,1); y=coord(:,2);
xy = coord';
t=linspace(0,1,66); airfoil = csapi(t,coord'); figure(2) fnplt(airfoil) hold on plot(x,y,'r*') axis equal
s1=0.1; s2=fnval(airfoil,s1) pin=[s1,min(s2)] plot(pin(1),pin(2),'og')
The S823 file could be found in the NREL website:
Thanks in advance!

Antworten (1)

Unai San Miguel
Unai San Miguel am 15 Mär. 2017
You are working with curves, not functions.
Your airfoil is a (planar) curve, or in the Splines toolbox wording a 2-valued, 1-variate spline function. This function is composed by two 1-valued, 1-variate functions which interpolate the pairs(t(i), x(i)) and (t(i), y(i)). With fnval(airfoil, s1) you are asking for the (x, y) coordinates for a value of t = 0.1.
You can see this if you plot the two components
airfoil_x = fncmb(airfoil, [1, 0]);
airfoil_y = fncmb(airfoil, [0, 1]);
figure(3)
clf
h1 = subplot(2,1,1);
fnplt(airfoil_y)
hold on
plot(t, y, 'o')
xlabel('t'), ylabel('y')
h2 = subplot(2,1,2);
fnplt(airfoil_x)
hold on
plot(t, x, 'o')
xlabel('t'), ylabel('x')
The point you asked for is found in these plots
errorbar(h1, s1, s2(2), s2(2) - h1.YLim(1), 0, 'k*')
errorbar(h2, s1, s2(1), s2(1) - h2.YLim(1), 0, 'k*')
And also in your original plot
figure(2)
plot(s2(1), s2(2), 'gsq', 'MarkerFaceColor', 'g')
If you want the point(s) over the airfoil at x = 0.1 you can do this:
  1. Find the zero(s) of the x-coordinate of your function minus the desired x-value
  2. Evaluate your funtion in those values of t
x0 = 0.1;
t0 = mean(fnzeros(fncmb(airfoil_x, '-', x0)), 1);
y0 = fnval(airfoil_y, t0);
airfoil_0 = fnval(airfoil, t0);
plot(h2, [0, 1], [x0, x0], 'g-')
errorbar(h2, t0, [x0, x0], [-5, -5], [5, 5], 'gsq', 'MarkerFaceColor', 'g')
h2.YLim = [0, 1];
h1.YLim = h1.YLim;
errorbar(h1, t0, y0, [-5, -5], [0, 0], 'gsq', 'MarkerFaceColor', 'g')

Community Treasure Hunt

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

Start Hunting!

Translated by