当前位置:网站首页>Matlab-实时编辑器介绍
Matlab-实时编辑器介绍
2022-07-27 09:56:00 【用户9925864】
在实时编辑器中,可以创建随代码一起显示代码输出的实时脚本。添加格式化文本、方程、图像和超链接用于增强记叙脚本,以及将实时脚本作为交互式文档与其他人共享。
在实时编辑器中创建实时脚本。要创建实时脚本,请在主页选项卡上,点击新建实时脚本。
添加人口统计数据
将实时脚本划分为多个节。每一节均可以包含文本、代码和输出。MATLAB 代码显示为灰色背景,输出显示为白色背景。要创建新的节,请转至实时编辑器选项卡,然后点击分节符按钮。
添加 1900 至 2000 年间美国的人口统计数据。
以可视方式呈现一段时间内的人口变化
各节可独立运行。要运行某节中的代码,请转至实时编辑器选项卡,然后点击运行节按钮。也可以点击在将鼠标移至节左侧时显示的蓝条。运行节时,输出和图窗会随生成这些内容的代码一起显示。
绘制不同年份的人口数据图。
是否可以预测 2010 年的人口?
拟合数据
将支持信息添加到文本中,包括方程、图像和超链接。
下面我们尝试使用多项式拟合数据。我们将使用 MATLAB polyfit 函数获取系数。
拟合方程为:
y=ax+b 线性y=ax2+bx+cy=ax3+bx2+cx+d.二次方三次方
x = (years-1900)/50;
coef1 = polyfit(x,pop,1)
coef1 = 1×2
98.9924 66.1296
coef2 = polyfit(x,pop,2)
coef2 = 1×3
15.1014 68.7896 75.1904
coef3 = polyfit(x,pop,3)
coef3 = 1×4
-17.1908 66.6739 29.4569 80.1414
绘制曲线图
创建具有任意数量的文本和代码行的节。
我们可以绘制用于拟合数据的线性、二次和立方曲线。我们使用 polyval 函数来计算在点 x 处的拟合多项式。
pred1 = polyval(coef1,x);
pred2 = polyval(coef2,x);
pred3 = polyval(coef3,x);
[pred1; pred2; pred3]ans = 3×11
66.1296 85.9281 105.7266 125.5250 145.3235 165.1220 184.9205 204.7190 224.5174 244.3159 264.1144
75.1904 89.5524 105.1225 121.9007 139.8870 159.0814 179.4840 201.0946 223.9134 247.9403 273.1753
80.1414 88.5622 101.4918 118.1050 137.5766 159.0814 181.7944 204.8904 227.5441 248.9305 268.2243下面我们绘制每个多项式的预测值。
hold on
plot(years,pred1)
plot(years,pred2)
plot(years,pred3)
ylim([50 300])
legend({'Data' 'Linear' 'Quadratic' 'Cubic'},'Location', 'NorthWest')
hold off可以将你的实时脚本与其他 MATLAB 用户共享,这样他们可以重现
你的结果。你也可以将结果发布为 PDF、Microsoft Word 或 HTML 文档。
在实时脚本中添加控件,可以向用户展示重要参数会对分析产生怎样的影响。要添加控件,请转至实时编辑器选项卡,点击控件按钮,然后从可用选项中进行选择。
我们现在可以使用三个方程计算预测的给定年份的人口。
边栏推荐
- Snowflake vs. Databricks谁更胜一筹?2022年最新战报
- System parameter constant table of system architecture:
- 超赞的卡尔曼滤波详解文章
- Is Damon partgroupdef a custom object?
- C # set different text watermarks for each page of word
- 并发之线程状态转换
- 使用 LSM-Tree 思想基于.NET 6.0 C# 写个 KV 数据库(案例版)
- I grabbed a ticket and thought I found the system bug of 12306
- Understand chisel language. 22. Chisel sequential circuit (II) -- detailed explanation of chisel counter: counter, timer and pulse width modulation
- 中高级试题」:MVCC 实现原理是什么?
猜你喜欢

历时一年,论文终于被国际顶会接收了
![Shell function, system function, basename [string / pathname] [suffix] can be understood as taking the file name in the path, dirname file absolute path, and user-defined function](/img/3d/d7276d2010f1d77a3bd572cc66eced.png)
Shell function, system function, basename [string / pathname] [suffix] can be understood as taking the file name in the path, dirname file absolute path, and user-defined function

Understand chisel language. 22. Chisel sequential circuit (II) -- detailed explanation of chisel counter: counter, timer and pulse width modulation

Why do microservices have to have API gateways?

When I went to oppo for an interview, I got numb

活体检测综述
![Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号](/img/31/ed0d8c1a5327059f2de7493bec1c6c.png)
Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号

LeetCode.814. 二叉树剪枝____DFS

Talk about 10 scenarios of index failure. It's too stupid

I haven't delivered books for a long time, and I feel uncomfortable all over
随机推荐
Stylegan paper notes + modify code to try 3D point cloud generation
LeetCode.565. 数组嵌套____暴力dfs->剪枝dfs->原地修改
Shell中的文本处理工具、cut [选项参数] filename 说明:默认分隔符是制表符、awk [选项参数] ‘/pattern1/{action1}filename 、awk 的内置变量
Shell流程控制(重点)、if 判断、case 语句、let用法、for 循环中有for (( 初始值;循环控制条件;变量变化 ))和for 变量 in 值 1 值 2 值 3… 、while 循环
pytorch的安装(非常详细)
安装CUDA失败的情况nsight visual studio edition失败
Snowflake vs. Databricks谁更胜一筹?2022年最新战报
S交换机堆叠方案配置指南
ACL2021最佳论文出炉,来自字节跳动
Food safety | the kitchen board environment is very important. Do you know these use details?
Dcgan paper improvements + simplified code
Leetcode.1260. 2D grid migration____ In situ violence / dimensionality reduction + direct positioning of circular array
TFlite 的简单使用
Interview Essentials: shrimp skin server 15 consecutive questions
Uninstall cuda11.1
Qt 学习(二) —— .pro文件详解
食品安全 | 还在吃酵米面吗?当心这些食物有毒!
Looking for a job for 4 months, interviewing 15 companies and getting 3 offers
Example of ICP registration for PCL
吃透Chisel语言.24.Chisel时序电路(四)——Chisel内存(Memory)详解