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

📄 curvfit2.sce

📁 source code for curve fitting includes regression mechanism
💻 SCE
字号:
function []=fit();printf("\n Enter File : ");fn=scanf("%s");fp=mopen(fn,'r');n=mfscanf(fp,'%d'); printf("\n Enter Order of Equation:");   ord=scanf("%d")for i=1:n,x(i)=mfscanf(fp,'%f');y(i)=mfscanf(fp,'%f');end      mclose(fp);               sigma_y=0; sigma_xy=0;         A(ord+1,ord+1)=0.0;           X(ord+1)=0.0;          for i=1:n,           sigma_y=sigma_y+y(i);            sigma_xy=sigma_xy+x(i)*y(i);          end               sigma(1)=n;        for j=2:(2*ord)+1,            sigma(j)=0;          for i=1:n,            sigma(j)=sigma(j)+(x(i)^(j-1));          end        end                  for j=1:ord+1,     // B matrix preparation         B(j)=0;          for i=1:n           B(j)=B(j)+y(i)*(x(i)^(j-1));          end         end                                          for i=1:ord+1,  // Equation Matrix  preparation          for j=1:ord+1,                   A(i,j)=sigma((i+j-1));           end          end                           //   X=Inv(A) * B                        X=B'*inv(A);                     for i=1:n,        // Preparation of Y values yp         yp(i)=0;          for j=1:ord+1,           yp(i)=yp(i)+(x(i)^(j-1))*X(j);          end                   end                    //  We know the a and b values  in A+Bx=Y  where Y=log y ;B=log b ; A=log a    xtitle("    CURVE -FIT   ","       X-Axis","         Y-Axis");    xset("color",3);        for i=1:n,         plot(x(i),y(i),'dg')    end     tot=0;    for i=1:n      tot=tot+(y(i)-yp(i))^2;    end    tot=tot/n;    printf("generalisation  error is:");    disp(tot);     for i=1:n      tot=tot+abs(y(i)-yp(i));    end    printf("absolute value of error is");    disp(tot/n);       //scf(1);       xset("color",2);    plot(x,yp)    xtitle("    CURVE -FIT   ","       X-Axis","         Y-Axis");            endfunction;

⌨️ 快捷键说明

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