MATLAB的应用 Applications of MATLAB in engineering

文章目录

(〇)前言——【先看看】

  本文是对MATLAB一些应用的介绍。可以帮助理解MATLAB的功能和用法
  后面会慢慢更新具体的MATLAB在工程中的一些应用
   学习于B站视频,整理出来一些学习资料。英文版的,也可以提升英语能力
   这里也推荐一些最基础入门的学习网站
                http://c.biancheng.net/matlab/
                https://www.ilovematlab.cn/resources/
   需要word版的可以下载附件资源
   一些源代码也会在我的另一份博文里提供
       源代码https://blog.csdn.net/Nirvana_Tai/article/details/105391688
   有交流或者建议可以联系我    QQ:1756170618

(一) 【Basic operation(introduce MATLAB)】——【基本操作(介绍MATLAB)】:

i. search Function name by online or help
ii. variable,and search its type in double click or input whos(which is more
in detail than who)
iii. π=pi,∞=Infinitely small=eps,NaN:not a number,i,j=complex number
iv. sqrt: square root
v. no use built-in function or keyword as variable name, if you use it, must clear this variable name
vi. format+bank(short/long/shortE/rat and so on)
bank: two decimal places
short: four decimal places
long: many decimal places
scientific notation +E
traction rat
vii. command line terminal:use ;
viii. Press the arrow key to bring it up and down command history
ix. Input “clear”to remove all workspace,input”clc”to remove all command window

(二) 【Matlab as calculator】,【Array operation】——【Matlab作为计算器】、【数组运算】:

i. Basic:use “[ ]”to express array
ii. Row vector—[ ];column vector—[ ; ; ; ; ]
iii. Inner product;outer product This like this:[1 1 1][1;1;1]is inner product, [1;1;1] [1 1 1]is outer product.
iv. Matrix:use semicolon to divide each row
v. Indexing:input array name with(row,column)
Addition:input A(1,:) to index all value in third row
在这里插入图片描述
vi. Replace entries:
在这里插入图片描述
If want to delect which row or column,using A(x,:)=[ ]
vii. Colon operator:equal difference series
Like A=1(first number value):1(equal difference):50(final number value)
viii. Array concatenation:use F=[A(array one) B(array another)]
ix. Array manipulation:look out:AB different with A.B
Array +constant:A
x Array transposition:A’
x. Some special Matrix
 eye(n):n
n identity matrix
 zeros(n1,n2):n1n2 zero matrix
 ones(n1,n2):n1
n2matrix with every entry as 1
 diag( ):diagonal matrix
xi. Some Matrix related functions
 max(A):index and show max entry in every column
 max(max(A)): index and show max entry in array
 sum(A):sum each entry in every column
 mean(A):mean in every column
 sort(A):sort entry’s size in each column
 sortrows(A):sort first column’s entries and sort it with rows
 size(A):the size of matrix
 length(A):the column’s length
 find(A==x)
xii. some operation
 Matrix determinant: det(A)
 Inverse matrix: inv(A) or A^-1
 adjoint matrix: A*=det(A)inv(A)
 prod(1:n)=n!
 1e100=1
10^100

(三) 【Script writing】,【structured programming】,【User-defined function】——【脚本编写】、【结构化编程】、【自定义函数】:

i. Script editor: % as annotation,%% to divide section
Debug: use breakpoint
Smart indent: inverse blank space
ii. Script flow: typically scripts run from the first line to the last
Flow control,
relational operators: ~=:not equal to
&&:and ||:or
It is logical, because it belong to Boolean
在这里插入图片描述
iii. If/elseif/else: ,”elseif”and”else” are optional
[‘even’ even number ’odd’ odd number]
iv. Edit grammar
‘disp’ is means ‘printf’which in C language
‘input_(xxx)’ is means ‘int()’
v. Switch :
在这里插入图片描述
vi. While:
在这里插入图片描述
vii. For:
在这里插入图片描述
viii. Pre-allocating space to variables: if not pre-allocating space to variables will spend more
time to debug. Can record time.
在这里插入图片描述
ix. Break:
x. Tips for script writing:
 Use semicolon(😉:inhibit unwanted output
 Use ellipsis(…):to make scripts more readable
 Use smart forming
 Use ‘ctrl+c’ to stop operate
xi. Content of matlab built-in functions:
 Looking for source code:use “edit(which(‘function.m’))varargin
 Function have keyword,output,file name,input
xii. User define function:
 Like ‘freebody’
[.*(./)is more useful]
Some functions:input,isemply,break,disp,num2str
xiii. Function default variables:
 Nargout:number of function input arguments
 Varargin:variablr length input argument list
 Varargout:variablr length output argument list
xiv. Function handles: 在这里插入图片描述 ’f’ is a function handle

(四) 【Variables:string,strcture,cell】,【Date access】——【变量:字符串、结构、单元格】、【数据库访问】:

i. Matlab date(variable) types:
Use ‘int8()’ to transform types
ii. Transform the char to hex(ASCII): using ‘uint16( )’
iii. Logical operations and assignments:
Seek,compare and input
iv. Structure: as (student.name)
v. Adding information to a structure: add (2)… like(student(2).name)
vi. Structure functions:
Like (fieldname( )) and (refiled( ))
vii. Nesting structures:
To input a structures which be made of many other structures.
Like this: 在这里插入图片描述
xiii. Cell array:
a) Another method of soring heterogeneous date,it is similar to matrix but each entry contains different type of date.
b) Declaresd using {}
在这里插入图片描述
Or can use method like “A{1,1}=[1,2,3;2,3,4;3,4,5]…”
xiv. Accessing Cell array:
Use A{1,1} to get {1,1}array.
Use A{1,1}(1,1) to get {1,1}array’s (1,1) number
xv. Cell array functions: click this website to look for cell array functions
a) num2cell:
在这里插入图片描述
b) mat2cell:
在这里插入图片描述
xvi. Multidimensional array:
a) Include rows,columns,layers
You can use 在这里插入图片描述to make it,but it is flexible and inefficient
b) Array concatenation: cat()
Like this:
在这里插入图片描述
xvii. Reshape:
在这里插入图片描述
xviii. Checking variable and variable status:
Using ‘isfunction’ to determine
xix. File access:
A. High-level file input/output:
a) save() and load():

  1. save(all) workspace date to a file:
    在这里插入图片描述
  2. load date stored in a file:
    在这里插入图片描述
    b) Excel file reading: xlsread()
    在这里插入图片描述
    c) Excel file writing: xlswrite()
    在这里插入图片描述
    ‘04Score.xlsx’ is filename 1 is sheet
    M is variable ‘E2:E4’ is location
    Mean(A) is to calculate each column in A
    Mean(A’) is to calculate each row in A and show with 13
    Mean(A’)’ is to calculate each row in A and show with 3
    1
    d) Getting text in excel spreadsheet:
    Getting both the text and numbers:
    在这里插入图片描述
    B. Low-level file input/output:
    a) Read and write file at the byte or character level.
    b) File I/O functions: click
    c) Writing sine values into a file:
    在这里插入图片描述
    d) Read and write through formatted I/O:
    在这里插入图片描述
    e) Reading from files: fscanf(fid, , )
    在这里插入图片描述
    Check if it is the end of file:

(五) 【Basic plotting】,【Graphical object properties】——【基础绘图】、【图形对象属性】:

i. Plot()
If you not input instruct, the new plot will take place of the old ones
ii. Hold on/off: to have both plots in one figure
iii. plot style: plot(x,y,’str’) ,using the format defined in str(check linespec)
iv. legend( ):add legend to graph
v. title( ) and ?lable( )
slash pi(\pi) to show as π; use “{ }”to show special sign
vi. text( ) and annotation( ):
linspace:Generate linearly spaced vector
vii. figure adjustment:
【Graphical objects: Figure object, Axes object, Line object】
Figure property: in the figure’s editor
viii. Modifying properties of an object:
a) Identifying the handle of object:
b) Fetching or modifying properties:
c) Get object properties:
d) Setting axes limits:
Using set(gca,’XLim’,[0,2*pi]);
e) Setting font and tick of axes
Using set(gca,’FontSize’,25);
f) Line specification:
Using set(h,’LineStyle’,’-‘,…
‘LineWidth’,7.0,’Color’,’g’);
ix. Marker specification:
Face and edge colors of the marker.
在这里插入图片描述
x. Multiple figures:
Create a figure window by calling
Ps: the difference between gcf and gca
xi. Figure position and size:
在这里插入图片描述
xii. Several plots in one figure:
Several small plots“in a figure”
在这里插入图片描述
在这里插入图片描述
xiii. Control of Grid,Box,and Axis:
在这里插入图片描述
xiv. Saving figures into files:
在这里插入图片描述
xv. grid on; means show grid
axis square sets the current coordinate figure to a square. The ratio of the horizontal axis to the vertical axis is 1:1
axis equal sets the scaling coefficient of the horizontal and vertical axes to the same value

(六) 【Advanced 2D plots】,【Color space】,【3D plots】——【高级2D绘图】、【色彩空间】、【3D绘图】:

i. What forms appropriate to you:
在这里插入图片描述
ii. Special plots:
在这里插入图片描述
iii. Logarithm plots:
在这里插入图片描述
iv. Plotyy(): SC
在这里插入图片描述
v. Histogram: SC
在这里插入图片描述
vi. Bar charts: SC
在这里插入图片描述
vii. Stacked and Horizontal Bar Charts: SC
在这里插入图片描述
在这里插入图片描述

viii. Pie charts:
在这里插入图片描述
ix. Polar charts:
在这里插入图片描述
The SC of N polygon
x. Stairs and Stem charts:
在这里插入图片描述
The exercise’s SC,which as followed.
在这里插入图片描述

xi. Boxplot and Error Bar:
在这里插入图片描述
xii. fill()

  1. stop sign: SC
    fill() is to fill the color in the figure
    xiii. Color space:
    在这里插入图片描述
    click to check color chart:
    color chart:

xiv. Visualizing date and an image : imagesc()

  1. Display values of a matrix as an ‘image’ SC
    在这里插入图片描述
    在这里插入图片描述

  2. Color bar and scheme:

    在这里插入图片描述

在这里插入图片描述
Nature colormap(cool) colormap(hot)
4. Built-in Colormaps
在这里插入图片描述

xv. 3D Plots:
在这里插入图片描述
xvi. More 3D Line Plots:
在这里插入图片描述
xvii. Principles for 3D Surface Plots:
A. Surface plots:mesh() and surf(): SC
在这里插入图片描述
xviii. contour():
projection of equal heights of 3D plot onto a 2D plane.
在这里插入图片描述在这里插入图片描述
xix. meshc() and surfc():
combination of surface/mesh and contours
在这里插入图片描述
xx. View Angle: view()
Vary the view angle in the script below
在这里插入图片描述在这里插入图片描述
the latter SC
xxi. Light : light()
Light('Position’,[ , , ])
Set(L1.’Position’,[ , , ])
xxii. patch()
a graphical object containing polygons
xxiii. Matlab plots can be very professional!
在这里插入图片描述
its SC

(七) 【Graphical user interface】——【图形用户界面】:

i. Matlab GUI programs:
在这里插入图片描述
ii. Starting a GUI programs:
在这里插入图片描述
iii. GUI figure
Display the names of the GUI components

  1. Select File>Preferences>GUIDE
  2. Check”show names in compenent palette”
    iv.
    在这里插入图片描述to reserve some files about GUI
    v. Align the components:
    Select Tools>Align objects
    vi. Label the Push Buttons:
    Select View>Property Inspector [double click]
    vii. GUI script structure:
    Function untitled_OpeningFcn
    Insert under this module: as followed
    在这里插入图片描述
    viii. Callback of an Object:
    Make some buttons callback to different running. As followed.
    在这里插入图片描述
    ix. What if we have two axes?
    The latest figure will show on.
    x. handles-Parents of the GUI Objects:
    在这里插入图片描述
    xi. setting the axes for Plotting:
    在这里插入图片描述
    xii. Review-set() and get():
    get() acquires properties
    set() set properties
    在这里插入图片描述
    xiii. Using handles to store variables:
    在这里插入图片描述
    xiv. Compiling the GUI program
    Deploytool

(八) 【introduction to digital image】,【read and show images】,【image arithmetic】——【数字图像概论】、【图像读取与显示】、【图像算法】:

i. Digital image and its Acquisition:
在这里插入图片描述
ii. Types of digital image:
Color, gray scale, binary
在这里插入图片描述
iii. Where does the color come from:
在这里插入图片描述
iv. Typical RGB image:
v. Elements of images:
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
vi. Read and show an image:
 Read an image: imread()
 Show an image: imshow()
vii. Image variable in workspace:
在这里插入图片描述
viii. Image info:
在这里插入图片描述
ix. Image viewer: imtool(‘pout.tif’)
Get pixel information in image viewer
x. Image processing:
Any form of signal processing for which the input is an image
xi. Image arithmetic:
在这里插入图片描述
xii. Image multiplication: immultiply()
在这里插入图片描述
xiii. Image addition: imadd()
在这里插入图片描述
xiv. Image Histogram: imhist()
在这里插入图片描述 YLable is number of pixel,XLable is graylevel
xv. Histogram Equalization: histeq()
在这里插入图片描述
xvi. Geometric transformation:
Moving the coordinates of the pixels in an image
xvii. Geometric transformation Matrices(2D)
在这里插入图片描述
xviii. Image rotation: imrotate()
在这里插入图片描述
xix. Image Rotation:
在这里插入图片描述
xx. Write image: imwrite():
在这里插入图片描述

(九) 【Image thresholding】,【Background estimation】,【Connected-component labeling】——【图像阈值化】、【背景估计】、【连通分量标注】:

i. Image thresholding:
A gray-level image can be turned into a binary image by using a threshold.
ii. graythresh() and im2bw(): SC
graythresh() computes an optimal threshold level
Im2bw() converts an images into binary image
在这里插入图片描述
iii. Issues of the Binary image:
 existing sparkles in the background
 some grains are missing
iv. Background estimation:
在这里插入图片描述
v. Background substraction:
在这里插入图片描述
vi. Thresholding on background removed image:
在这里插入图片描述
vii. Connect-component labeling:
在这里插入图片描述
viii. Connect-component labeling: bwlabel()
在这里插入图片描述
ix. Color-coding objects: label2rgb() SC
在这里插入图片描述
x. Object properties: regionprops() SC
在这里插入图片描述
xi. Interactive selection: bwselect() SC
在这里插入图片描述

(十) 【Polynomial differentiation and integration】,【Numerical differentiation and integration】——【多项式微分与积分】、【数值微分与积分】:

i. Differentiation:
在这里插入图片描述
ii. Polynomial differentiation:
在这里插入图片描述
iii. Representing polynomials in MATLAB:
在这里插入图片描述
iv. Values of polynomials: poluval() SC
在这里插入图片描述
v. Polynomial differentiation: polyder()
在这里插入图片描述
vi. Convolution: conv()
Exercise: SC
在这里插入图片描述
vii. Polynomial integration:
在这里插入图片描述
K is a constant
viii. Polynomial integration:
在这里插入图片描述
ix. Numerical differentiation:
在这里插入图片描述
x. Differences: diff()
Calculates the differences between adjacent elements of a vector
xi. Numerical differentiation using diff()
在这里插入图片描述
xii. How to find the f’ over an interval [0,2pi]? SC
在这里插入图片描述
xiii. Various step size
在这里插入图片描述
xiv. Second and Third derivatives:
在这里插入图片描述
xv. Numerical integration:
在这里插入图片描述

xvi. Numerical Quadrature rules:
在这里插入图片描述

xvii. Midpoint rule:
在这里插入图片描述

xviii. Midpoint rule using sum()
在这里插入图片描述

xix. Trapezoid rule:
在这里插入图片描述

xx. Trapezoid rule using trapz()
在这里插入图片描述

xxi. Second-order rule:1/3 Simpson’s
在这里插入图片描述

xxii. Simpson’s rule:
在这里插入图片描述

xxiii. Comparison:
在这里插入图片描述
xxiv. Review of Function Handles(@)
 A handle is a pointer to a function
 Can be used to pass functions to other functions
在这里插入图片描述

xxv. Numerical integration: integra1()
在这里插入图片描述

xxvi. Double and Triple integrals: 在这里插入图片描述

(十一) 【symbolic approach】,【numeric root solvers】,【recursive function】——【符号法】、【数值根求解】、【递归函数】:

i. Problem statement:
在这里插入图片描述
在这里插入图片描述
ii. Symbolic root finding approach:
在这里插入图片描述
在这里插入图片描述

iii. Symbolic root finding: solve()
在这里插入图片描述
iv. Solving multiple equations:
在这里插入图片描述
v. Solving equations expressed in symbols:
在这里插入图片描述
vi. Symbolic differentiation: diff()
在这里插入图片描述
vii. Symbolic integration: int()
在这里插入图片描述
viii. Symbolic vs. Numertic:
在这里插入图片描述
ix. fsolve:
在这里插入图片描述
x. fzero:
在这里插入图片描述
xi. finding roots of polynomials: roots()
在这里插入图片描述
xii. how do there solves find the roots:
在这里插入图片描述
xiii. Numeric root finding methods:
在这里插入图片描述
xiv. Bisection method(Bracking)
在这里插入图片描述
xv. Newton-Raphson method(open)
在这里插入图片描述
xvi. Bisection vs. Newton-Raphson
在这里插入图片描述
xvii. Recursive function
在这里插入图片描述
xviii. Factorial recursive function
在这里插入图片描述

(十二) 【Statistics】——【统计】:

i. Statistic
 The science of”date”
 Involving the collection,analysis,interpretation,presentation,and organization of date
ii. Main statistical methodologies
在这里插入图片描述
iii. Summary mersures:
在这里插入图片描述
iv. Mean,Media,Mode,and Quartile
在这里插入图片描述
v. Range and interquartile range
在这里插入图片描述
vi. Variance and Standard Deviation:
在这里插入图片描述
vii. Figures are always more poweful:
在这里插入图片描述
viii. Boxplot exanple:
在这里插入图片描述
ix. Skewness:
在这里插入图片描述
x. Skewness: skewness()
在这里插入图片描述
xi. Kurtosis:
在这里插入图片描述
xii. Statistical hypothesis testing
在这里插入图片描述
xiii. Hypothesis testing procedure:
在这里插入图片描述
xiv. Terminology in Hypothesis testing:
在这里插入图片描述
xv. t-test example:
在这里插入图片描述
xvi. Two-tailed significance test:
在这里插入图片描述
xvii. One-tailed significance test:
在这里插入图片描述
xviii. Common Hypothesis tests:
在这里插入图片描述
Matlab functions

The book consists chapters illustrating a wide range of areas where MATLAB tools are applied. Many interesting problems have been included throughout the book, and its contents will be beneficial for students and professionals in wide areas of interest. These areas include mathematics, physics, chemistry and chemical engineering, mechanical engineering, biological (molecular biology) and medical sciences, communication and control systems, digital signal, image and video processing, system modeling and simulation. Contents 1 Application of GATES and MATLAB for Resolution of Equilibrium, Metastable and Non-Equilibrium Electrolytic Systems 2 From Discrete to Continuous Gene Regulation Models – A Tutorial Using the Odefy Toolbox 3 Systematic Interpretation of High-Throughput Biological Data 4 Hysteresis Voltage Control of DVR Based on Unipolar PWM 5 Modeling & Simulation of Hysteresis Current Controlled Inverters Using MATLAB 6 84 Pulse Converter, Design and Simulations with Matlab 7 Available Transfer Capability Calculation 8 Multiuser Systems Implementations in Fading Environments 9 System-Level Simulations Investigating the System-on-Chip Implementation of 60-GHz Transceivers for Wireless Uncompressed HD Video Communications 10 Low-Noise, Low-Sensitivity Active-RC Allpole Filters Using MATLAB Optimization 11 On Design of CIC Decimators 12 Fractional Delay Digital Filters 13 On Fractional-Order PID Design 14 Design Methodology with System Generator in Simulink of a FHSS Transceiver on FPGA 15 Modeling and Control of Mechanical Systems in Simulink of Matlab 16 Generalized PI Control of Active Vehicle Suspension Systems with MATLAB 17 Control Laws Design and Validation of Autonomous Mobile Robot Off-Road Trajectory Tracking Based on ADAMS and MATLAB Co-Simulation Platform 18 A Virtual Tool for Computer Aided Analysis of Spur Gears with Asymmetric Teeth 19 The Use of Matlab in Advanced Design of Bonded and Welded Joints 20 ISPN: Modeling Stochastic with Input Uncertainties Using an Interval-Based Approach 21 Classifiers of Digital Modulation Based on the Algorithm of Fast Walsh-Hadamard Transform and Karhunen-Loeve Transform 22 Novel Variance Based Spatial Domain Watermarking and Its Comparison with DIMA and DCT Based Watermarking Counterparts 23 Quantitative Analysis of Iodine Thyroid and Gastrointestinal Tract Biokinetic Models Using MATLAB 24 Modelling and Simulation of pH Neutralization Plant Including the Process Instrumentation
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TaiBai-let

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值