⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyfunction.m

📁 这是用于工程测量进行大坝变形分析的软件
💻 M
字号:
function result=polyfunction(x0,y0,before_cigema_squre,temp)
global edit2 edit3 edit4 edit5 fit2
for i=1:length(x0)-1
      [temp_a,temp_b,temp_c,temp_d,cigema_squre(i)]=poly_nihe(x0,y0, i);%样条拟合
end
[cigema_squre_diff,location]=min(abs(cigema_squre-before_cigema_squre));
[a,b,c,d,cigema_squre(location)]=poly_nihe(x0,y0,location);%样条拟合
phasenum=location;
num=fix((length(x0)-1)/phasenum);   %平均分的话,每段所占有的点数
rest_num=(length(x0)-1)-phasenum*num;%平均分剩下的点;
for i=1:phasenum
    if rest_num~=0
        phase_num(i)=num+1;%每段享有的点数
        rest_num=rest_num-1;
    else 
        phase_num(i)=num;
    end
end      
%画出样条线                 
for j=1:phasenum            
    total=0;
    for t=1:j
       total=total+phase_num(t);
    end
    end_num=total+1;%该段末点点号          
    begin_num=end_num-phase_num(j);  %该段起点点号
    t=x0(begin_num):0.1:x0(end_num);
    plot(t,a(j).*t.^3+b(j).*t.^2+c(j).*t+d(j),'r');
    hold on; 
end                             
plot(x0,y0,'b*')
if nargin==3
   title('这是整个滑坡在所求方向的样条拟合图');
elseif nargin==4
   title(['这是第' num2str(temp) '个点在所求方向的样条拟合图']);
end 
xlabel(['从' get(edit2,'string') '年' get(edit4,'string')  '月到' get(edit3,'string')  '年' get(edit5,'string') '月']);
ylabel('在滑坡方向的位移量/米');
hold off; 
%写函数参数------------------------------------------------------------------------------------------------------        
if nargin==3 
    fprintf(fit2,'以下是整个滑坡样条曲线拟合结果\n')  ;
    fprintf(fit2,'其方差σ=%f\n',cigema_squre(location));
elseif nargin==4
    fprintf(fit2,['以下是第' num2str(temp)  '点样条曲线拟合结果\n']) ;
    fprintf(fit2,'其方差σ=%f\n',cigema_squre(location));
end
fprintf(fit2,['共分为' num2str(phasenum)  '段\n']);
for i=1:phasenum
    fprintf(fit2,['第' num2str(i) '段的拟合函数为\n']);
    fprintf(fit2,[num2str(a(i)) 'x^3+' num2str(b(i)) 'x^2+' num2str(c(i)) 'x+' num2str(d(i)) '\n']);
end
fprintf(fit2,'各参与拟合点的信号及噪声为\n') ;
for j=1:phasenum            
    total=0;
    for t=1:j
       total=total+phase_num(t);
    end
    end_num=total+1;%该段末点点号          
    begin_num=end_num-phase_num(j);                           %该段起点点号
    for i=begin_num:end_num
        y=a(j).*x0(i).^3+b(j).*x0(i).^2+c(j).*x0(i)+d(j);
        fprintf(fit2,['y' num2str(i) '的信号为' num2str(y*1000) 'MM\t' '噪声为' num2str((y0(i)-y)*1000) 'MM\n']);
    end
end
%--------------------------------------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -