MATLAB的使用总结

Log scale

 1 %# some random data
 2 x = 2.^(0:10);
 3 y = rand(size(x));
 4 
 5 plot(log2(x), y)                               %# plot on log2 x-scale
 6 set(gca, 'XTickLabel',[])                      %# suppress current x-labels
 7 
 8 xt = get(gca, 'XTick');
 9 yl = get(gca, 'YLim');
10 str = cellstr( num2str(xt(:),'2^{%d}') );      %# format x-ticks as 2^{xx}
11 hTxt = text(xt, yl(ones(size(xt))), str, ...   %# create text at same locations
12     'Interpreter','tex', ...                   %# specify tex interpreter
13     'VerticalAlignment','top', ...             %# v-align to be underneath
14     'HorizontalAlignment','center');           %# h-aligh to be centered

设置label位置

xlabh = get(gca,'XLabel');
set(xlabh,'Position',get(xlabh,'Position) - [0 .2 0])

这一句会使得xlabel向下0.2个单位,单位就是y轴的单位。如果y轴的单位是10^5,那么就需要0.2*10^5才能看得出移动了。。。

非线性拟合

1 x=[2 5 8 10 20 40 60 80 100 300 1000];
2 y=[0.0066  0.0095  0.0119  0.0123  0.0207  0.0770  0.1787  0.3410  0.4961  0.8486  1.0000 ];
3 fun=inline('1-exp(-(x./a(1)).^a(2))','a','x')
4 a=lsqcurvefit(fun,[0.4 0.9],x,y)

inline指定函数形式。a(1)为第一个参数,a(2)为第二个需要拟合的参数……[0.4 0.9]对应于每个参数的初值。

1 a =
2     0.5340   -9.0991

也就是最后的函数为 1-exp(-(x/0.5340)^(-9.0991))。

posted @ 2014-05-02 15:24  linyx  阅读(285)  评论(0编辑  收藏  举报