MATLAB
【sources】
F:【3】MATLAB【】MATLAB书籍【chinapub】matlab教程一套电子书【】
【】02MATLAB启动
日期和时间:
![](https://app.yinxiang.com/shard/s72/res/565a1329-26d0-4279-822f-8be45acff17a.png)
![](https://app.yinxiang.com/shard/s72/res/f284c487-9b7b-4ed8-9d86-d6a4a8665506.png)
数字输出格式:
![](https://app.yinxiang.com/shard/s72/res/75214305-8223-4169-a719-c10ed783bab7.png)
demo 打开帮助窗口
lookfor sine 查找sine相关的函数等内容
使用what列出当前文件夹中存放的M文件
![](https://app.yinxiang.com/shard/s72/res/476c49c0-a57e-4e1f-9553-17082d0fafcc.png)
系统命令:
![](https://app.yinxiang.com/shard/s72/res/0898c9aa-deaa-412a-94e4-04c0fce82423.png)
【】03矩阵运算
cross(x,y)叉积
dot(x,y)点积
Ax=b ,x=A;使用左除比用逆和乘法所需的运算次数要少;
![](https://app.yinxiang.com/shard/s72/res/a7e7291f-10a3-4d6a-84a1-c1415b34fe8a.png)
find函数
![](https://app.yinxiang.com/shard/s72/res/4c7f5768-3cd0-4288-b0da-f7e7c1e7994b.png)
【】04 创建矩阵
ones(3,5);
![](https://app.yinxiang.com/shard/s72/res/3e093b6a-1a97-45d6-859c-f961e1967bf0.png)
![](https://app.yinxiang.com/shard/s72/res/76468e85-b44e-4e6b-b683-e95876a244e6.png)
![](https://app.yinxiang.com/shard/s72/res/2c6bddf7-8af0-48d2-aef4-eaf2e25812c3.png)
![](https://app.yinxiang.com/shard/s72/res/85cee969-4a28-4c2c-abbe-e23176790673.png)
![](https://app.yinxiang.com/shard/s72/res/7dbd3eae-86f8-4c7f-a1e3-1420d053ed96.png)
![](https://app.yinxiang.com/shard/s72/res/dc07c146-00a6-4e2c-8e30-911298c1e81d.png)
![](https://app.yinxiang.com/shard/s72/res/d743b684-cf13-4a71-9c69-8d7365fcf7f2.png)
【】第5章 字符串和其他数据类型
![](https://app.yinxiang.com/shard/s72/res/2462ec2b-3e96-46fe-b492-cc9202ff3e63.png)
![](https://app.yinxiang.com/shard/s72/res/47dd3b92-ae55-4563-80ef-09f5fe1842eb.png)
![](https://app.yinxiang.com/shard/s72/res/419f4a40-d9b7-4540-9351-cb1421873f25.png)
![](https://app.yinxiang.com/shard/s72/res/8c27d139-67b8-4bdb-adce-1e2eb689f4c5.png)
![](https://app.yinxiang.com/shard/s72/res/547f5e07-b26a-40a1-9c8c-de9c4b25cc9a.png)
5.2整数
![](https://app.yinxiang.com/shard/s72/res/09fe1f05-b333-4923-a36b-b2b9a3db73c8.png)
素数、余数、排列、等
5.3 位操作
![](https://app.yinxiang.com/shard/s72/res/f62333f5-f750-4b48-ad39-b875baaa4036.png)
5.4 集合操作
![](https://app.yinxiang.com/shard/s72/res/37acde02-e071-439b-ae49-76c574400b38.png)
求解集合的交集、并集、差集等
5.5 细胞矩阵
![](https://app.yinxiang.com/shard/s72/res/0f096ad7-18dd-4d4e-a19c-940d226633e3.png)
第6章 数据分析和统计
6.1 求最大值、最小值
![](https://app.yinxiang.com/shard/s72/res/b7a95c2c-caef-4edb-ab78-f08d391a4be2.png)
max对矩阵求最大值是对每一列进行操作
6.2 求和、乘积、差分
![](https://app.yinxiang.com/shard/s72/res/fbeef8d0-ce78-4715-872b-bbfb07fd8ced.png)
![](https://app.yinxiang.com/shard/s72/res/c02da770-bbfc-4cb7-a5ae-8d9498a133d9.png)
![](https://app.yinxiang.com/shard/s72/res/b459b56f-514c-4174-9f5c-b2d4aacaf9ee.png)
其中梯度可计算离散的梯度,如下:
![](https://app.yinxiang.com/shard/s72/res/d64e9e9e-4156-4e63-9801-8f9da64898d6.png)
6.3 统计命令
![](https://app.yinxiang.com/shard/s72/res/f9ab158a-cc3a-416b-b97b-106f19d69a05.png)
![](https://app.yinxiang.com/shard/s72/res/597b64aa-f55b-4e46-bb78-e86d9698c0ca.png)
6.4 排序
![](https://app.yinxiang.com/shard/s72/res/0e425e18-2946-404a-975c-f6c6b4de45f8.png)
6.5 统计频数直方图和棒图
![](https://app.yinxiang.com/shard/s72/res/00d3112d-d0a6-45f8-b25b-209969cbd1cf.png)
得到的voronoi图形如下:
![](https://app.yinxiang.com/shard/s72/res/4dea5d39-cfcd-49aa-9c39-ba71503509a5.png)
![](https://app.yinxiang.com/shard/s72/res/c10a014f-b764-4be9-8de8-034ba7643dde.png)
第7章 线性方程系统
![](https://app.yinxiang.com/shard/s72/res/000ffd71-4c85-4b1f-a7d0-fd6de394adde.png)
![](https://app.yinxiang.com/shard/s72/res/efdbf225-dd1f-447f-8c27-c17b84fa795b.png)
![](https://app.yinxiang.com/shard/s72/res/c028b049-c0cc-43f3-b889-cf49f8250884.png)
![](https://app.yinxiang.com/shard/s72/res/75c98f6c-9d21-4bd3-9970-54cad1e89710.png)
![](https://app.yinxiang.com/shard/s72/res/a907aaae-ee71-4a2a-b49d-654e6c763652.png)
![](https://app.yinxiang.com/shard/s72/res/d91c909e-6a6c-4002-87b0-81d611432d8c.png)
![](https://app.yinxiang.com/shard/s72/res/ca9e88fa-29f9-4c75-a4d4-b4ec28423aad.png)
![](https://app.yinxiang.com/shard/s72/res/23b7048a-1292-4435-99f6-47fb78236977.png)
![](https://app.yinxiang.com/shard/s72/res/60f85692-f9f3-4aec-b0ba-9749aa9c218c.png)
![](https://app.yinxiang.com/shard/s72/res/a248b4f1-9169-4072-8161-0b69900a763e.png)
![](https://app.yinxiang.com/shard/s72/res/af462dd5-9197-4356-9634-a53fef4c6de5.png)
![](https://app.yinxiang.com/shard/s72/res/0109e469-e3c3-4b4c-b46e-df5421375c9f.png)
![](https://app.yinxiang.com/shard/s72/res/82256c33-ae47-4c01-9f31-7589b78430de.png)
![](https://app.yinxiang.com/shard/s72/res/441a6146-b808-4042-a342-fe7d904d77b3.png)
第8章 特征值和特征向量
![](https://app.yinxiang.com/shard/s72/res/107e4586-ac88-45ca-b567-a65f08b9aaee.png)
![](https://app.yinxiang.com/shard/s72/res/e75c47e3-7c0d-4d6f-9af0-f6e1d9e5c038.png)
![](https://app.yinxiang.com/shard/s72/res/6ece29c9-d0f3-4989-972c-b0fa3ef5381f.png)
![](https://app.yinxiang.com/shard/s72/res/c8adfd07-6194-4413-a101-f414c62a5015.png)
![](https://app.yinxiang.com/shard/s72/res/fda0ce08-1aaa-442a-8da7-3025b991b9c8.png)
![](https://app.yinxiang.com/shard/s72/res/2492f269-1923-448d-865f-397a2b4be921.png)
![](https://app.yinxiang.com/shard/s72/res/21a981ed-777b-4694-91b6-bf164788aa7b.png)
![](https://app.yinxiang.com/shard/s72/res/7a2e781b-c69e-488b-b1e7-b0c2373b6460.png)
第9章 稀疏矩阵
![](https://app.yinxiang.com/shard/s72/res/d5c6984e-8441-4f8a-8896-3356fa12c838.png)
![](https://app.yinxiang.com/shard/s72/res/63259a9d-b7c9-4c36-8266-6b63ea4e3492.png)
![](https://app.yinxiang.com/shard/s72/res/0dd3d2a2-a55f-4880-9950-b232b4aa8766.png)
![](https://app.yinxiang.com/shard/s72/res/1a192540-6f85-41bf-837a-529887269be0.png)
![](https://app.yinxiang.com/shard/s72/res/1ec5ea49-5710-4572-b5e8-f8b7cda5f38d.png)
![](https://app.yinxiang.com/shard/s72/res/033503c5-7107-40a5-aec4-97e80c6db5f6.png)
![](https://app.yinxiang.com/shard/s72/res/0b50c313-a4a8-4e99-ae87-dd3ffb888876.png)
![](https://app.yinxiang.com/shard/s72/res/a83fba4f-1b15-4a7c-b6b0-9f359e2f5598.png)
![](https://app.yinxiang.com/shard/s72/res/9bc50651-3237-49e8-8e31-61653c24a357.png)
![](https://app.yinxiang.com/shard/s72/res/19e2d2b3-27aa-44ee-810d-55c08655b08b.png)
![](https://app.yinxiang.com/shard/s72/res/def93035-dc24-47ef-ae51-31445a7f92e3.png)
![](https://app.yinxiang.com/shard/s72/res/1e38ce8e-40f3-4334-a1ab-d5870e680263.png)
上面的网格图形与图论中的内容是一样的。
第10章 函数、插值和曲线拟合分析
10.1 MATLAB中的多项式
![](https://app.yinxiang.com/shard/s72/res/df350388-406c-42a8-91cf-abde6c286291.png)
![](https://app.yinxiang.com/shard/s72/res/33a34aef-2120-43e5-b1e7-455661ad222d.png)
10.2 函数的零值
![](https://app.yinxiang.com/shard/s72/res/5eea7923-369b-41bb-a3b7-fb5ca41b8b21.png)
10.3 函数的最小值和最大值
![](https://app.yinxiang.com/shard/s72/res/c498ea3c-7ca6-4f48-b6bd-f953506762f7.png)
10.4 插值、曲线拟合和曲面拟合
![](https://app.yinxiang.com/shard/s72/res/eaf9aa2b-4f91-4dc0-8458-6243d478630e.png)
![](https://app.yinxiang.com/shard/s72/res/7cd96838-46c1-42df-bfde-093923f14fb5.png)
![](https://app.yinxiang.com/shard/s72/res/0b3a4e4b-921d-451b-88de-b0a2532e341d.png)
![](https://app.yinxiang.com/shard/s72/res/b41b5a9f-56b7-4087-96d2-e7569b1f007f.png)
![](https://app.yinxiang.com/shard/s72/res/ef198ce7-d171-44fd-bbe7-d4dcf7841e68.png)
第11章 积分和微分方程组
第12章 MATLAB程序设计(内容比较多)
首先是基本的流程控制语句
条件语句 if
循环语句 for 循环 while 循环
function test(x)
if x>1
disp('x bigger than 1 and...');
if x>2
disp('x is bigger than 2');
else
disp('x is bettwen 1 and 2');
end
elseif x>0
disp('x bigger than 0')
else
disp('x is smaller than 0');
end
switch x
case 1
disp('x is eqaul to 1');
case 2
disp('x is equal to 2');
case {3, 4,5}
disp('x is in 3 4 5 ');
case {'tangyuanjie','tyj'}
disp('this is my name');
otherwise
disp('x is neither 1 nor 2');
end
a=[];
for k = 1:5
for j=1:5
if k ==j
a(k,k)=5;
elseif abs(k-j) ==1
a(k,j)=1;
else
a(k,j)=0;
end
end
end
a
![](https://app.yinxiang.com/shard/s72/res/26943347-963b-4789-9a99-26a4f29fdee5.png)
暂停几秒钟
终值循环
终值并提示错误信息
声明全局变量
获得运行文件的名称
控制警告信息(不提示,只提示一次)
子函数的调用
函数作为传递参数
![](https://app.yinxiang.com/shard/s72/res/3fbb9061-cfb8-473f-b36a-652d1f52ba06.png)
结构体
![](https://app.yinxiang.com/shard/s72/res/3644a82e-4c94-4aa2-b7f6-5db4d5e23e55.png)
对象 和methods方法
![](https://app.yinxiang.com/shard/s72/res/9bd9f1ec-2876-437b-9957-f6fe914939ed.png)
![](https://app.yinxiang.com/shard/s72/res/5c33f84b-da5c-4463-a7de-c2e8caa4be92.png)
调试和计时
![](https://app.yinxiang.com/shard/s72/res/8ef4ad13-060a-45f5-bcf6-4b2488827f61.png)
![](https://app.yinxiang.com/shard/s72/res/2c944af4-729f-4925-ad26-29c5f07d6956.png)
![](https://app.yinxiang.com/shard/s72/res/c5d00eb1-696d-4ddc-8ff3-368455708521.png)
![](https://app.yinxiang.com/shard/s72/res/c5d00eb1-696d-4ddc-8ff3-368455708521.png)
![](https://app.yinxiang.com/shard/s72/res/df748f32-171d-473e-b473-d77951f59216.png)
通过计时可以判断不同程序的执行效率,
如下实例:
![](https://app.yinxiang.com/shard/s72/res/b9babfcc-0c3e-4ed6-a754-614d6b80c6e5.png)
第13章 图形和声音
MATLAB 拥有大量简单、灵活、易用的二维和三维图形命令,并且用户可以在 MATLAB 程序中加入声音效果。许多图形命令都在 MATLAB所带的演示程序中给出。使用demo命令即可。
![](https://app.yinxiang.com/shard/s72/res/f9cc85c3-0c0b-4046-9355-df8cae32dfb3.png)
点的类型,线型,颜色;
![](https://app.yinxiang.com/shard/s72/res/5605d93f-a3d0-45ed-92b6-ff40ea796c66.png)
】各种颜色的英文全称:
green 绿色
megenta 品红色
blue 蓝色
cyan 灰色
white 白色
red 红色
black 黑色
yellow 黄色
![](https://app.yinxiang.com/shard/s72/res/d4604859-3aac-4226-bc71-def0fa4ce353.png)
】交换参数的位置相当于交换坐标轴的位置:
>> plot(x,a)
>> hold on
>> plot(a,x)
![](https://app.yinxiang.com/shard/s72/res/30847c36-e218-465c-8a8f-ef86738a5647.png)
】指定线宽; 标记点的颜色、大小
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
figure
plot(x,y,'--gs',...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])
y = tan(sin(x)) - sin(tan(x));
figure
plot(x,y,'--gs',...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])
】绘制时间刻度
t = 0:seconds(30):minutes(3);
y = rand(1,7);
plot(t,y,'DurationTickFormat','mm:ss')
】指定坐标轴绘制图像
figure % new figure
ax1 = subplot(2,1,1); % top subplotax2 = subplot(2,1,2); % bottom subplot
x = linspace(0,3);
y1 = sin(5*x);
y2 = sin(15*x);
plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')
plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
y1 = sin(5*x);
y2 = sin(15*x);
plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')
plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
ylabel(ax2,'sin(15x)')
图形如下:
![](https://app.yinxiang.com/shard/s72/res/f24fb954-384e-4509-89ca-078b675af31d.png)
】创建图形之后更改线条参数
】中断线条
plot([1,2,NaN,4,5])
![](https://app.yinxiang.com/shard/s72/res/d183c82f-74a5-475f-9d44-b9711938709c.png)
![](https://app.yinxiang.com/shard/s72/res/e6c2e6b2-e711-466f-96b7-9ddc1fce43be.png)
![](https://app.yinxiang.com/shard/s72/res/752c0751-a9f1-4d7d-aa04-911b54f4af1b.png)
![](https://app.yinxiang.com/shard/s72/res/cefbbda3-39a7-450a-8338-c5825359efc7.png)
![](https://app.yinxiang.com/shard/s72/res/385a8fd5-8822-46a2-ab8d-a21d12c71f9b.png)
![](https://app.yinxiang.com/shard/s72/res/18875774-2165-4f12-aa50-e67501a17d23.png)
![](https://app.yinxiang.com/shard/s72/res/e854892d-1ec3-4a93-a548-93e2eed3c822.png)
![](https://app.yinxiang.com/shard/s72/res/b3e5243f-f348-4732-be31-545ad6a35c20.png)
![](https://app.yinxiang.com/shard/s72/res/3a83aa7b-9f2b-4e70-9494-d7e67bc6d272.png)
窗口命令:
![](https://app.yinxiang.com/shard/s72/res/3cdc1650-7a91-48bf-8a51-4eb3a32b1217.png)
![](https://app.yinxiang.com/shard/s72/res/72f2367a-85ae-4089-a9ec-8f4c8c3bdd33.png)
![](https://app.yinxiang.com/shard/s72/res/ebb604e6-8713-4b15-8fa0-6438898172a5.png)
![](https://app.yinxiang.com/shard/s72/res/5fb94d3c-dd8b-4d42-a768-487c074af6a2.png)
![](https://app.yinxiang.com/shard/s72/res/47fbf6df-4171-47bd-9f66-e9ad2da1d766.png)
![](https://app.yinxiang.com/shard/s72/res/59a89251-0ee4-4f3e-ab0b-9fe39cb4571b.png)
![](https://app.yinxiang.com/shard/s72/res/63693bd2-53f0-48e0-b7fc-3883a03910a4.png)
![](https://app.yinxiang.com/shard/s72/res/9b19871a-d19c-496a-9b51-2d1ebc3bbafa.png)
![](https://app.yinxiang.com/shard/s72/res/81b071e7-a18c-4591-86df-3248e2a57f83.png)
交互式画图:
![](https://app.yinxiang.com/shard/s72/res/77c63e15-d01a-4eb6-aa52-6720d2c860a8.png)
生成网格和绘制等高线图
![](https://app.yinxiang.com/shard/s72/res/50f7a6ac-7a3a-423d-8376-6755311b3236.png)
![](https://app.yinxiang.com/shard/s72/res/556771c6-cccb-4583-8df0-6d4f8be97a69.png)
![](https://app.yinxiang.com/shard/s72/res/e4fec471-3d96-4d46-8c14-c86460589f25.png)
![](https://app.yinxiang.com/shard/s72/res/5010f10c-3960-4952-974a-5445e0052806.png)
![](https://app.yinxiang.com/shard/s72/res/716096aa-58f2-402f-9f0e-1c8c606fe81c.png)
![](https://app.yinxiang.com/shard/s72/res/89a23211-c94c-4262-bc54-923e5ca38b20.png)
![](https://app.yinxiang.com/shard/s72/res/271a6812-1d36-4d84-95fa-8c9f9fe2f50a.png)
![](https://app.yinxiang.com/shard/s72/res/ed8d0cc5-09ea-4aab-bfd0-28332d3ee84b.png)
![](https://app.yinxiang.com/shard/s72/res/8d950ef8-7927-4e35-b44b-ec8ceda3a6cb.png)
![](https://app.yinxiang.com/shard/s72/res/5941b948-0d77-43d5-90b3-92fc8501a078.png)
![](https://app.yinxiang.com/shard/s72/res/e00e41b5-0178-44cf-8729-870a6003dd13.png)
![](https://app.yinxiang.com/shard/s72/res/01c3d65c-cec1-42e9-a01f-d44e0c17b98b.png)
![](https://app.yinxiang.com/shard/s72/res/94cdbbf0-f96b-4a21-a7d2-a24052d8c2be.png)
![](https://app.yinxiang.com/shard/s72/res/a863fe77-0d59-4854-8d4e-5b22c10428f9.png)
![](https://app.yinxiang.com/shard/s72/res/43175bc1-bdf9-4834-a44b-e643bb1aab57.png)
![](https://app.yinxiang.com/shard/s72/res/063c9af9-de8b-40e6-9d7a-72e5eebb21ed.png)
![](https://app.yinxiang.com/shard/s72/res/2a48e65a-60ed-4bd7-bd66-9fcd5c70b872.png)
声音:
![](https://app.yinxiang.com/shard/s72/res/03a1ef0f-fc62-4e1e-887e-e1fdde2968de.png)
![](https://app.yinxiang.com/shard/s72/res/a75e897e-97af-458e-a00b-484166f22716.png)
![](https://app.yinxiang.com/shard/s72/res/2564d08b-07aa-482b-9763-ce55f3d66e4d.png)
第14章 高级图形
图的结构
![](https://app.yinxiang.com/shard/s72/res/97aa4a9e-4a0c-476f-83d0-212d6cdad93f.png)
更改图的部分属性:
![](https://app.yinxiang.com/shard/s72/res/e1829202-75fb-40b3-b9c9-6bc3d27c6531.png)
![](https://app.yinxiang.com/shard/s72/res/d12240ee-aa3c-4143-9a1a-c83941de46e1.png)
![](https://app.yinxiang.com/shard/s72/res/027a0995-367b-4baa-8e3f-7e9608042756.png)
![](https://app.yinxiang.com/shard/s72/res/51ecf36d-77a9-4030-ba61-4dc404b8b399.png)
![](https://app.yinxiang.com/shard/s72/res/5e319bdb-5046-4950-9521-2d043278cc94.png)
![](https://app.yinxiang.com/shard/s72/res/1e852a74-1984-4136-b902-d23fb940477a.png)
![](https://app.yinxiang.com/shard/s72/res/769b521f-9833-4282-9ae6-96b4aa70d1f9.png)
![](https://app.yinxiang.com/shard/s72/res/3c99f78e-7baf-4e4f-b160-bb47fa45c4cd.png)
![](https://app.yinxiang.com/shard/s72/res/5664dc78-b2f2-4079-a35a-dd87e25f7277.png)
动画等
第15章 MATLAB与其他编程语言结合
![](https://app.yinxiang.com/shard/s72/res/a608831d-1b40-44ef-b82c-8e41bbab2590.png)
![](https://app.yinxiang.com/shard/s72/res/e8f7d54c-037d-4135-bce8-712aaede3f54.png)
![](https://app.yinxiang.com/shard/s72/res/0c934c73-fc1b-481d-b76d-ad2d1502005c.png)
![](https://app.yinxiang.com/shard/s72/res/47eb7ea2-c3aa-48db-ae8d-f71e1487c4f3.png)