从库安装:
sudo apt-add-repository ppa:octave/stable
sudo apt-get update
sudo apt-get install octave
使用:以ceres拟合曲线结果为例
手动复制数据:
1 x = [0:0.01:1]; 2 a1 = 1.0, b1 = 2.0 , c1 = 1.0, w = 1.0; 3 y1 = exp(a1*x.^2 + b1*x + c1)+w; 4 plot(x,y1,"r") 5 hold on 6 7 A = [0 2.71828;0.01 2.93161;0.02 2.12942;0.03 2.46037;0.04 4.18814;0.05 2.73368;0.06 2.42751;0.07 3.44729;0.08 3.72543;0.09 2.1358;0.1 4.12333;0.11 3.38199;0.12 4.81164;0.13 1.62582;0.14 1.76862;0.15 3.21555;0.16 3.0922;0.17 5.82752;0.18 4.29855;0.19 2.74081;0.2 5.75724;0.21 3.53729;0.22 1.95514;0.23 2.99195;0.24 3.28739;0.25 4.70749;0.26 6.24365;0.27 5.81645;0.28 4.88402;0.29 4.75991;0.3 7.25246;0.31 5.92933;0.32 7.00306;0.33 5.22286;0.34 5.16179;0.35 7.26191;0.36 6.40545;0.376.25549;0.38 6.56094;0.39 6.53523;0.4 8.14891;0.41 7.77616;0.42 7.40141;0.43 8.75638;0.44 7.20606;0.45 7.57795;0.46 8.21564;0.47 9.84032;0.48 6.96725;0.49 9.90619;0.5 9.27125;0.51 9.87567;0.52 10.3412;0.53 9.55315;0.54 11.3635;0.55 10.8815;0.56 13.0648;0.57 11.4756;0.58 11.337;0.59 13.2393;0.6 13.5299;0.61 14.0441;0.62 13.31;0.63 13.672;0.64 14.8504;0.65 14.2599;0.66 14.7724;0.67 17.4339;0.68 17.4632;0.69 17.7598;0.7 16.8223;0.71 19.9468;0.72 20.5446;0.73 21.3767;0.74 20.1435;0.7520.3088;0.76 23.2543;0.77 23.4349;0.78 22.8706;0.79 24.094;0.8 25.4183;0.81 25.5237;0.82 27.9738;0.83 28.5861;0.84 29.5703;0.85 29.6744;0.86 32.667;0.87 34.2698;0.88 33.5124;0.89 36.1479;0.9 39.2485;0.91 40.988;0.92 41.5716;0.93 41.3686;0.94 44.285;0.95 42.8312;0.96 47.7941;0.97 48.5931;0.98 51.8487;0.99 51.0258]; 8 plot(A(:,1),A(:,2)) 9 scatter(A(:,1),A(:,2)) //或plot(A(:,1),A(:,2),'.') 10 hold on 11 12 a2 = 0.891943, b2 = 2.17039, c2 = 0.944142; //ceres得到的结果 13 y2 = exp(a2*x.^2 + b2*x + c2) + w; 14 plot(x,y2,"b") 15 16 xlabel('x') 17 ylabel('y') 18 title('ceres')
在终端使用script命令保存数据:
1 script -a data.txt
运行程序,运行完毕使用exit命令结束。
1 exit
打开文件进行数据处理。
进入Octave界面。
1 data = load ("data.txt"); 2 plot (data (:,1), data (:,2),".");
即可绘制出点。