当前位置:网站首页>Matlab tips (29) polynomial fitting plotfit
Matlab tips (29) polynomial fitting plotfit
2022-07-07 06:50:00 【mozun2020】
MATLAB Tips (29) Polynomial fitting plotfit
Preface
MATLAB Learning about image processing is very friendly , You can start from scratch , There are many encapsulated functions that can be called directly for basic image processing , This series of articles is mainly to introduce some of you in MATLAB Some concept functions are commonly used in routine demonstration !
Polynomial fitting is to use a polynomial expansion to fit all observation points in a small analysis area containing several analysis lattice points , Get the objective analysis field of the observation data . The expansion coefficient is determined by least square fitting . However, the domain polynomial of this method is quasi merge unstable , This is especially true when data is missing , And it will cause the analysis to be discontinuous between the fitting regions .
When analyzing and predicting data , More common fitting methods , The fitting polynomial is obtained by the least square method , Thus, the predicted value of the parameter can be predicted , The example encountered when searching for data , Here to share , This article example simulation MATLAB Version is MATLAB2015b.
One . MATLAB Simulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function : Polynomial fitting
% Environmental Science :Win7,Matlab2015b
%Modi: C.S
% Time :2022-06-28
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% I. Clear environment variables
clear all
clc
tic
y=[100.3 101.1 102.1 101.1 101.6 104.4 102.5 102.1 103.9 103.9];
x=1:length(y);
A=polyfit(x,y,2) %2 Secondary phase fitting , This 2 Modifiable Model coefficients
Z=polyval(A,x); % forecast y
len=[1:20];
len1=polyval(Z,len); % Predict the trend
result=[y;Z]% Actual value and predicted value
error=abs(y-Z);% error
bfb=error./y% Relative error
errorsum=sum(error)/length(y)% Average error
bfbsum=sum(bfb)/length(y)% Average relative error
figure(1)
plot(x,y,'r-',x,Z,'b-')
legend(' actual value ',' Fit value ')
title(' Comparison between actual value and predicted value ','fontsize',15)
ylabel('Y','fontsize',15)
xlabel('X','fontsize',15)
figure(2)
plot(len,len1,'b-')
legend(' Fit the curve ')
title(' Fitting curve ','fontsize',15)
ylabel('Y','fontsize',15)
xlabel('X','fontsize',15)
toc
Two . Simulation results
A =
-0.0144 0.5159 100.0167
result =
100.3000 101.1000 102.1000 101.1000 101.6000 104.4000 102.5000 102.1000 103.9000 103.9000
100.5182 100.9909 101.4348 101.8500 102.2364 102.5939 102.9227 103.2227 103.4939 103.7364
bfb =
0.0022 0.0011 0.0065 0.0074 0.0063 0.0173 0.0041 0.0110 0.0039 0.0016
errorsum =
0.6300
bfbsum =
0.0061
Time has passed 2.561846 second .
3、 ... and . Summary
Simulation example of polynomial fitting , It may be used later , Take a note here . Learn one every day MATLAB Little knowledge , Let's learn and make progress together !
边栏推荐
- Go straight to the 2022ecdc fluorite cloud Developer Conference: work with thousands of industries to accelerate intelligent upgrading
- Linear algebra (1)
- oracle如何备份索引
- How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet
- sqlserver多线程查询问题
- 网络基础 —— 报头、封装和解包
- Problems and precautions about using data pumps (expdp, impdp) to export and import large capacity tables in Oracle migration
- MYSQL binlog相关命令
- Force deduction 62 different paths (the number of all paths from the upper left to the lower right of the matrix) (dynamic planning)
- MATLAB小技巧(29)多项式拟合 plotfit
猜你喜欢
How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet
Can't you really do it when you are 35 years old?
BindingException 异常(报错)处理
二十岁的我4面拿到字节跳动offer,至今不敢相信
Apache ab 压力测试
Abnova 膜蛋白脂蛋白体技术及类别展示
学术报告系列(六) - Autonomous Driving on the journey to full autonomy
多个kubernetes集群如何实现共享同一个存储
Cloudcompare point pair selection
A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are
随机推荐
JESD204B时钟网络
MySQL (x)
地质学类比较有名的外文期刊有哪些?
libcurl返回curlcode说明
隐马尔科夫模型(HMM)学习笔记
企业如何进行数据治理?分享数据治理4个方面的经验总结
大促过后,销量与流量兼具,是否真的高枕无忧?
C language (structure) defines a user structure with the following fields:
Basic DOS commands
ip地址那点事
怎样查找某个外文期刊的文献?
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
docker-compose启动redis集群
Cloudcompare point pair selection
What books can greatly improve programming ideas and abilities?
Prompt for channel security on the super-v / device defender side when installing vmmare
Several index utilization of joint index ABC
MySQL的安装
js装饰器@decorator学习笔记
Wechat applet hides the progress bar component of the video tag