当前位置:网站首页>捡起MATLAB的第(8)天
捡起MATLAB的第(8)天
2022-04-23 15:54:00 【Sola_Ex】
捡起MATLAB的第八天
Matlab
一维线性插值
一维插值命令
%x:原始数据(自变量)n维向量
%v:原始数据(函数值)n维向量
%xq:插值(自变量)可以使一个点,也可以是向量
%vq:插值结果(函数值)
vq = interp1(x,v,xq)
vq = intterp1(x,v,xq,method)
method的方法
2014a版本的matlab目前有这几种方法:

举例1 — 插值法:

实现脚本代码如下:
production = [75.995 ... .... ..] %此处省了,实则是产量的值
years = 1900:10:2010; %设置年份区间
x = 1900:2010;
p_res = interp1(years,production,x,'spline')
plot(years,production,'o',x,p_res)

运行就可以得到一个连续的线。
举例2 — 插值法:

实现脚本代码如下:
x = 0:2:24;
y = [....] %温度的值
% 注意:x和y的维度要一样,形成一一对应关系
x1 = 0:1/3600:24 %单位化成秒,增量为1s
strmethod={
'nearest',...} %方法
strlb={
'{a}method=nearest',...} %对应上方的方法
for i=1:6
y1 = interp1(x,y,x1,strmethod{
i});
subplot(3,2,i) %切割出3*2张图
plot(x,y,'ro',x1,y1,'b''linewith',1.5)
xlabel(strlb)
end
效果如下:

版权声明
本文为[Sola_Ex]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42312125/article/details/107743835
边栏推荐
- Method 2 of drawing ROC curve in R language: proc package
- Distinct use of spark operator
- Extract non duplicate integers
- [self entertainment] construction notes week 2
- gps北斗高精度卫星时间同步系统应用案例
- c语言---字符串+内存函数
- Control structure (I)
- 时序模型:长短期记忆网络(LSTM)
- Intersection, union and difference sets of spark operators
- MySQL optimistic lock to solve concurrency conflict
猜你喜欢

The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?

多线程原理和常用方法以及Thread和Runnable的区别

新动态:SmartMesh和MeshBox的合作新动向

Pgpool II 4.3 Chinese Manual - introductory tutorial

Configuration of multi spanning tree MSTP

APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)

Spark 算子之distinct使用

Cap theorem

Large factory technology implementation | industry solution series tutorials

New developments: new trends in cooperation between smartmesh and meshbox
随机推荐
js正则判断域名或者IP的端口路径是否正确
The length of the last word of the string
Treatment of idempotency
One brush 313 sword finger offer 06 Print linked list from end to end (E)
Go语言数组,指针,结构体
Spark 算子之distinct使用
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
字符串排序
一文掌握vscode远程gdb调试
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
Merging of Shanzhai version [i]
【第5节 if和for】
s16.基于镜像仓库一键安装containerd脚本
Distinct use of spark operator
[section 5 if and for]
MySQL集群模式与应用场景
【现代电子装联期末复习要点】
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
单体架构系统重新架构
多级缓存使用