学会matlab,就多了一个科研小助手
moboyou 2025-04-15 13:12 16 浏览
Matlab 介绍——Introduction to Matlab
分享兴趣,传播快乐,增长见闻,留下美好。
亲爱的您,
这里是LearingYard学苑!
今天小编为大家带来matlab介绍
欢迎您的用心访问!
本期推文阅读时长大约6分钟,请您耐心阅读。
Share interest, spread happiness, increase knowledge, and leave beautiful.
Dear you,
This is the LearingYard Academy!
Today, the editor brings you an introduction to matlab
Welcome your visit!
This tweet usually takes about 6 minutes to read, please read it patiently.
#01本期主题介绍
The topic of this issue
如果您学会使用Matlab,
将有一个科研小助手,做事更轻松!
本期话题将对matlab做一个基础介绍。
Matlab的功能多样,
这里介绍一下Matlab“入门级”的基本功能,
目的是给没有接触过Matlab的朋友学习参考。
所以,请感兴趣的朋友和小编开启学习Matlab的旅程吧!
If you can use Matlab, you will have an additional research assistant.
Do things more easily!
The topic of this issue will do a tweet introduction to matlab.
The functions of Matlab are quite diverse,
Here is an introduction to the basic functions of Matlab "entry level",
The purpose is to learn reference for friends who have not contacted Matlab.
So,
Please open with interested friends and editors
Let's get to know the journey of Matlab!
#02Matlab软件介绍
Matlab software introduction
MATLAB 是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境
MATLAB is a commercial mathematical software produced by MathWorks, a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numerical calculation.
主要用途:
(1)数值和符号计算;
(2)绘图;
(3)工具箱(Toolbox),分为功能性和学科性两种类。
使用技巧:Help
输入help funname (函数名),即可以得到函数的相关帮助信息。
The main purpose:
(1) Numerical value and symbol calculation;
(2) Drawing;
(3) Toolbox (Toolbox) is divided into two categories: functional and disciplinary.
Use skills: Help
Enter help funname (function name) to get help information about the function.
#03Matlab基础界面介绍
Matlab basic interface introduction
1.Matlab的基础界面The basic interface of Matlab
1)菜单工具栏
2)文件目录
3)命令窗口:交互式地控制Matlab。比如,简单计算,函数命令测试等。
4)数据区:命令中使用的变量、导入的数据、执行的脚本后的数据都会显示在此处。
5)代码编辑区:编辑代码,按菜单栏“运行”Matlab便可执行。
1) Menu toolbar
2) File directory
3) Command window: Control Matlab interactively. For example, simple calculation, function command test, etc.
4) Data area: The variables used in the command, the imported data, and the data after the executed script will all be displayed here.
5) Code editing area:Edit the code and press "Run" Matlab in the menu bar to execute it.
#04Matlab基本使用介绍
Introduction to the basic use of Matlab
1.命令窗口的使用(绘制正弦曲线和余弦曲线)
The use of the command window (drawing sine curve and cosine curve)
操作: 在命令窗口输入
x=[0:0.5:360]*pi/180;plot(x,sin(x),x,cos(x));
Operation: Enter in the command window
x=[0:0.5:360]*pi/180;plot(x,sin(x),x,cos(x));
2.变量命名规则
2. Variable naming rules
1、变量赋值
1. Variable assignment
变量命名:以字母开头,后接字母、数字或下划线的字符序列,最多63个字符;变量名区分字母的大小写。
变量赋值:变量名=表达式
表达式 [自动赋值给变量ANS]
举例:在命令窗口输入
x=1+2i,y=3-sqrt(17)
z=(cos(abs(x+y))-sin(78*pi/180))/(x+abs(y))
Variable naming: start with a letter, followed by a sequence of letters, numbers or underscores, up to 63 characters; variable names are case sensitive
Variable assignment: variable name = expression
Expression [automatically assigned to variable ANS]
Example: Enter in the command window
x=1+2i,y=3-sqrt(17)
z=(cos(abs(x+y))-sin(78*pi/180))/(x+abs(y))
3.矩阵操作(Matrix operation)
1)矩阵的建立
直接输入法:将矩阵元素用方括号括起来,按矩阵行的顺序输入各元素,同一行各元素之间用空格或逗号分隔,不同行的元素之间用分号分隔
2)利用冒号表达式建立一个行向量:e1:e2:e3
其中e1为初始值,e2为步长,e3为终止值;定义时可以不使用中括号、e2,默认步长为1。
1)The establishment of matrix
Direct input method: Enclose the matrix elements in square brackets, and enter the elements in the order of the matrix rows. The elements in the same row are separated by spaces or commas, and the elements in different rows are separated by semicolons.
2) Use the colon expression to create a row vector: e1:e2:e3
Among them, e1 is the initial value, e2 is the step size, and e3 is the end value; the brackets and e2 may not be used in the definition, and the default step size is 1.
3)用linspace函数产生行向量
linspace(a,b,n)。其中a和b是生成向量的第一个和最后一个元素,n是元素总数。linspace(a,b,n)与a:(b-a)/(n-1):b等价。具体操作如下图所示:
Use the linspace function to generate a row vector: linspace(a,b,n). Where a and b are the first and last elements of the generated vector, and n is the total number of elements. linspace(a,b,n) is equivalent to a:(b-a)/(n-1):b.The specific operation is shown in the figure below:
4)特殊矩阵 Special matrix
空矩阵[ ]:不包含任何元素,阶数为0×0。
产生特殊矩阵的函数:zeros(m,n)[产生零矩阵]。
Empty matrix [ ]: does not contain any elements, and the order is 0×0.
A function to generate a special matrix: zeros(m,n) [generate a zero matrix].
ones[产生全1矩阵]、eye[产生单位矩阵]
ones[generate all 1 matrix], eye[generate identity matrix]
rand[产生0~1间均匀分布的随机矩阵]、randn[产生均值为0,方差为1的标准正态分布随机矩阵]
rand[Generate a uniformly distributed random matrix between 0 and 1], randn[generate a standard normal distribution random matrix with a mean value of 0 and a variance of 1]
魔方矩阵:每行、每列及两条对角线上的元素和都相等;magic(n)生成一个n阶魔方阵。
具体操作如下图所示:
Magic cube matrix: the sum of the elements in each row, column and two diagonals are equal; magic(n) generates an n-order magic cube matrix.
The specific operation is shown in the figure below:
5.matlab之线性规划函数
Linprog( )对应的线性规划模型
min z=cx
Ax≤b
x≥0
[x,fval]=linprog(c,A,b,Aeq,beq,lb,ub)
其中,x返回线性规划的最优解(列向量)
fval返回目标函数最优值
c为目标函数系数(行/列向量)
A,b对应不等式约束A·x≤b
Aeq,beq对应等式约束Aeq·X=beq
lb,ub指定x的范围,即lb≤x≤ub,一般地,lb
为零向量,ub=[];b,beq,lb,ub均为列向量
举例:将下列模型转化为linprog格式
Min -z=-3x1-x2-4x3
sub.to 6x1+3x2+5x3≤45
3x1+4x2+5x3≤30
x1,x2,x3≥0
所以
c=[-3;-1;-4]; A=[6,3,5;3,4,5];
b=[45;30]; lb=zeros(3,1);
[x,fval]= linprog(c,A,b,[ ],[ ],lb,[ ])
计算机返回结果:x=(5;0;3),fval=-27
具体操作过程:
The linear programming model corresponding to Linprog( )
min z=cx
Ax≤b
x≥0
[x,fval]=linprog(c,A,b,Aeq,beq,lb,ub)
Among them, x returns the optimal solution of the linear programming (column vector).fval returns the optimal value of the objective function.c is the objective function coefficient (row/column vector).A, b corresponds to the inequality constraint A·x≤b.
Aeq, beq corresponds to the equality constraint Aeq·X=beq.lb,ub specifies the range of x, that is, lb≤x≤ub, generally, lb is a zero vector, ub=[ ]; b, beq, lb, ub are all column vectors
Example: Convert the following model to linprog format
Min -z=-3x1-x2-4x3
sub.to 6x1+3x2+5x3≤45
3x1+4x2+5x3≤30
x1, x2, x3≥0
so
c=[-3;-1;-4]; A=[6,3,5;3,4,5];
b=[45;30]; lb=zeros(3,1);
[x,fval]= linprog(c,A,b,[ ],[ ],lb,[ ])
The computer returns the result: x=(5;0;3), fval=-27
Specific operation process:
今天的分享就到这里了。
如果您对今天的文章有独特的想法,
欢迎给我们留言,
让我们相约明天,
祝您今天过得开心快乐!
That's it for today's sharing.
If you have a unique idea about today’s article,
Welcome to leave us a message,
Let us meet tomorrow,
I wish you a happy day today!
参考资料:电子工业出版社MATLAB教程第3版
英文翻译:Google翻译
本文由LearningYard学苑整理并发出,如有侵权请在后台留言!
LearningYard学苑
文案 | Qian
排版 | Qian
审核 | Tian
相关推荐
- 黄道十二宫杀手密码51年后被破解,来自两位程序员和数学家合作
-
杨净边策发自凹非寺量子位报道|公众号QbitAI黄道十二宫杀手(ZodiacKiller)可能是世界上最知名的高智商连环杀手,52年来从未被抓获。他的事迹已被改编成了多部好莱坞电影。△...
- 深入剖析MediaCodec解码器的基本原理及使用「建议新手收藏」
-
一,MediaCodec工作原理MediaCodec类Android提供的用于访问低层多媒体编/解码器接口,它是Android低层多媒体架构的一部分,通常与MediaExtractor、MediaMu...
- Retrofit WebService 实践
-
前言作为Android开发,平时和后端聊得最多的除了喝酒就是接口。常用语:Restful和WebService,前者现在聊得多,后者以前聊得多。默认含义分别为:Restful:HTTP协议...
- 建议收藏!175部4K UHD版本经典高分电影洗版参考目录(2015之前)
-
本内容来源于@什么值得买APP,观点仅代表作者本人|作者:1L789近两年很多经典高分老电影陆续开始重制成4KUHD版本,虽然我早已将这些电影的BD蓝光版收入,但纠结一番后还是花了不少时间将其全部...
- 2 个月的面试亲身经历告诉大家,如何进入 BAT 等大厂?
-
这篇文章主要是从项目来讲的,所以,从以下几个方面展开。怎么介绍项目?怎么介绍项目难点与亮点?你负责的模块?怎么让面试官满意?怎么介绍项目?我在刚刚开始面试的时候,也遇到了这个问题,也是我第一个思考的问...
- 详解Android官推Kotlin-First的图片加载库
-
前言Coil是一个非常年轻的图片加载库,在2020年10月22日才发布了1.0.0版本,但却受到了Android官方的推广,在AndroidDevelopersBackst...
- webview 渲染机制:硬件加速方式渲染的Android Web
-
webview渲染是什么?webview渲染是用于展现web页面的控件;webview可以内嵌在移动端,实现前端的混合式开发,大多数混合式开发框架都是基于webview模式进行二次开发的w...
- 因为我对Handler的了解,居然直接给我加了5K
-
1Handler是什么?android提供的线程切换工具类。主要的作用是通过handler实现从子线程切换回主线程进行ui刷新操作。1.1为什么Handler能实现线程切换?在创建Handler的...
- 「经典总结」一个View,从无到有会走的三个流程,你知道吗?
-
前言一个View,从无到有会走三个流程,也就是老生常谈的measure,layout,draw三流程我们都知道Android视图是由一层一层构成的层级结构,直白点说,就是父View包含子View而子V...
- 这些垃圾代码是谁写的?哦,原来小丑竟是我自己
-
程序员是最喜欢自嘲、自黑的群体之一,比如他们常常称自己是“码农”、“程序猿”,再比如他们的工作明明是写代码、修Bug,也有人调侃说:“明明我们是修代码、写Bug!”本文整理了一些程序员“修代码、写...
- 手把手教你爬取天堂网1920*1080大图片(批量下载)——理论篇
-
/1前言/平时我们要下载图片,要要一个一个点击下载是不是觉得很麻烦?那有没有更加简便的方法呢?答案是肯定的,这里我们以天堂网为例,批量下载天堂网的图片。/2项目准备工作/首先我们第一步我们要安装...
- 音视频开发需要你懂得 ffmpeg 开源库的编码原理
-
引言音视频开发需要你懂得音视频中一些基本概念,针对编解码而言,我们必须提前懂得编解码器的一些特性,码流的结构,码流中一些重要信息如sps,pps,vps,startcode以及基本的工作原理,...
- 「8年老 Android 开发」最全最新 Android 面试题系列全家桶(带答案)
-
下面跟大家分享的这些面试题都是互联网大厂真实流出的面试内容,每个问题都附带完整详细的答案,不像网上的那些资料三教九流有的甚至还没答案,这些面试题我也是经过日积月累才整理出来的精品资料。这些面试题主要是...
- 手把手教你爬取天堂网1920*1080大图片(批量下载)——实战篇
-
/1前言/上篇文章手把手教你爬取天堂网1920*1080大图片(批量下载)——理论篇我们谈及了天堂网站图片抓取的理论,这篇文章将针对上篇文章的未尽事宜进行完善,完成图片的批量抓取。/2图片网址解...
- PHP 8.1.9 更新发布
-
CLI:修复了内置服务器通过PHP_CLI_server_WORKERS环境变量的潜在溢出。修正了GH-8952(不再可能有意关闭std句柄)。Core:修复了GH-8923的错误(Windows上的...
- 一周热门
- 最近发表
- 标签列表
-
- curseforge官网网址 (16)
- 外键约束 oracle (36)
- oracle的row number (32)
- 唯一索引 oracle (34)
- oracle in 表变量 (28)
- oracle导出dmp导出 (28)
- oracle 数据导出导入 (16)
- oracle两个表 (20)
- oracle 数据库 字符集 (20)
- oracle安装补丁 (19)
- matlab化简多项式 (20)
- 多线程的创建方式 (29)
- 多线程 python (30)
- java多线程并发处理 (32)
- 宏程序代码一览表 (35)
- c++需要学多久 (25)
- c语言编程小知识大全 (17)
- css class选择器用法 (25)
- css样式引入 (30)
- html5和css3新特性 (19)
- css教程文字移动 (33)
- php简单源码 (36)
- php个人中心源码 (25)
- 网站管理平台php源码 (19)
- php小说爬取源码 (23)