我在Matlab中有这段代码,它应该采用翼型轮廓并增加点数,这样当我在另一个程序中绘制轮廓时,我将获得更平滑的曲线。
clear
%reading an external data file
fid = fopen('NACA0015.txt');
a = fscanf(fid,'%g %g',[2 inf]); % It has two rows now.
a = a'; % matrix transpose
n = input('200') %e.g., n=35
for i=1:n
for j=1:2
fprintf('%12.7f',a(i,j)); %a(i,1) is first column, a(i,2) is 2nd col
end
fprintf('\n');
end
fclose(fid);
for i=1:n
x(i)=a(i,1); %x , y vectors
y(i)=a(i,2);
end
% use spline to create more points
xx=0:0.01:1 % e.g., step =0.01 (number of points = (1-0)/0.01=100)
yy = spline(x,y,xx); % xx and yy are new generated values of Naca0012
fprintf('\n print spline values \n');
plot(xx,yy,'ro')
hold on
plot(x,y,'*')
当我运行此操作时,我收到错误
未定义的函数或变量'x'。
reading_external_data_and_spline出错(第26行) yy = spline(x,y,xx); %xx和yy是Naca0012的新生成值
我完全不知道为什么在代码中明确定义x变量时这不起作用,请有人帮我解决这个问题