Matlab 自定义函数拟合
2012-10-20 05:10
429 查看
%RandomAccess J0237_2 reference
%BasketballPass,BQSqare, BlowingBubbles,RaceHorses,
close all;
clear all;
RD = [
1507.09 40.64
755.76 36.89
376.83 33.56
196.96 30.77
1610.73 37.97
631.13 34.63
284.29 31.81
141.13 29.12
1634.23 38.18
749.48 34.79
353.55 31.62
166.08 28.72
1193.66 39.44
587.38 35.73
288.11 32.34
144.13 29.56
];
RD_s(1,1:4,1:2) = RD(1:4,:);
RD_s(2,1:4,1:2) = RD(5:8,:);
RD_s(3,1:4,1:2) = RD(9:12,:);
RD_s(4,1:4,1:2) = RD(13:16,:);
n = 4;
sample_number = 4;
colorset = {{'rx','r-','r--'},{'bo','b-','b--'},{'gd','g-','g--'},{'m+','m-','m--'}};
for seq_id = 1:1:n
x = RD_s(seq_id,:,1); %rate
y = RD_s(seq_id,:,2); %distortion
%method 1
fx = inline('a(1)*(x.^2) + a(2)*sqrt(x) + a(3)','a','x');
a = nlinfit(x,y,fx,[1 1 1]);
x1 = min(x):20:max(x);
y1 = a(1)*(x1.^2) + a(2)*sqrt(x1) + a(3);
%method 2
fx2 = polyfit(x,y,2);
yvalue = polyval(fx2,x);
x2 = x1;
y2 = polyval(fx2,x2);
%y2 = fx(1)*x1.^2 + fx(2)*x1 + fx(3); %polyval(fx,x1);
plot(x,y,colorset{1,seq_id}{1,1},x1,y1,colorset{1,seq_id}{1,2});
hold on
plot(x2,y2,colorset{1,seq_id}{1,3});
grid on;
end
% for seq_id = 1:1:n
% x = RD_s(seq_id,:,1); %rate
% y = RD_s(seq_id,:,2); %distortion
% fx = polyfit(x,y,2);
% yvalue = polyval(fx,x);
% x1 = 0:20:max(x);
% y1 = polyval(fx,x1);
% %y2 = fx(1)*x1.^2 + fx(2)*x1 + fx(3); %polyval(fx,x1);
% plot(x,y,colorset{1,seq_id}{1,1},x1,y1,colorset{1,seq_id}{1,2});
% hold on
% grid on;
% end
%BasketballPass,BQSqare, BlowingBubbles,RaceHorses,
close all;
clear all;
RD = [
1507.09 40.64
755.76 36.89
376.83 33.56
196.96 30.77
1610.73 37.97
631.13 34.63
284.29 31.81
141.13 29.12
1634.23 38.18
749.48 34.79
353.55 31.62
166.08 28.72
1193.66 39.44
587.38 35.73
288.11 32.34
144.13 29.56
];
RD_s(1,1:4,1:2) = RD(1:4,:);
RD_s(2,1:4,1:2) = RD(5:8,:);
RD_s(3,1:4,1:2) = RD(9:12,:);
RD_s(4,1:4,1:2) = RD(13:16,:);
n = 4;
sample_number = 4;
colorset = {{'rx','r-','r--'},{'bo','b-','b--'},{'gd','g-','g--'},{'m+','m-','m--'}};
for seq_id = 1:1:n
x = RD_s(seq_id,:,1); %rate
y = RD_s(seq_id,:,2); %distortion
%method 1
fx = inline('a(1)*(x.^2) + a(2)*sqrt(x) + a(3)','a','x');
a = nlinfit(x,y,fx,[1 1 1]);
x1 = min(x):20:max(x);
y1 = a(1)*(x1.^2) + a(2)*sqrt(x1) + a(3);
%method 2
fx2 = polyfit(x,y,2);
yvalue = polyval(fx2,x);
x2 = x1;
y2 = polyval(fx2,x2);
%y2 = fx(1)*x1.^2 + fx(2)*x1 + fx(3); %polyval(fx,x1);
plot(x,y,colorset{1,seq_id}{1,1},x1,y1,colorset{1,seq_id}{1,2});
hold on
plot(x2,y2,colorset{1,seq_id}{1,3});
grid on;
end
% for seq_id = 1:1:n
% x = RD_s(seq_id,:,1); %rate
% y = RD_s(seq_id,:,2); %distortion
% fx = polyfit(x,y,2);
% yvalue = polyval(fx,x);
% x1 = 0:20:max(x);
% y1 = polyval(fx,x1);
% %y2 = fx(1)*x1.^2 + fx(2)*x1 + fx(3); %polyval(fx,x1);
% plot(x,y,colorset{1,seq_id}{1,1},x1,y1,colorset{1,seq_id}{1,2});
% hold on
% grid on;
% end
相关文章推荐
- 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matlab拟合工具箱cftool
- 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matlab拟合工具箱cftool
- 数据拟合---使用自定义函数进行非线性拟合 -在Origin。matlab拟合工具箱cftool
- 用matlab实现自定义函数的数据拟合
- MATLAB 自定义函数拟合
- 用MATLAB做聚类分析时非常有用的自定义距离函数和标准化函数
- MATLAB自定义函数
- matlab调用自定义函数出现“尝试将 SCRIPT filter_low 作为函数执行:”的错误
- svm理论与实验之22: 自定义核函数在Matlab平台上的使用
- Matlab自定义函数的五种方法 [转]
- matlab自定义函数实现灰度图像均值滤波
- Matlab自定义函数的五种方法
- 关于matlab中数据拟合的一些函数polyfit()
- svm理论与实验之22: 自定义核函数在Matlab平台上的使用
- matlab/simulink中自定义c-s函数作为simulink模块使用实例
- matlab函数公式拟合
- MATLAB拟合函数使用说明
- Matlab函数拟合之Neural Network方法记录
- Matlab—将绘图保存为视频VideoWrite()函数用法与自定义视频尺寸
- Matlab中如何将(自定义)函数作为参数传递给另一个函数