MATLAB学习-基础篇

本文介绍了MATLAB中的基本操作,如清除工作区、清理命令窗口、格式化数字显示、导入导出数据、创建和操作向量,包括行向量、列向量、矩阵以及使用冒号和linspace进行均匀间隔元素生成。通过实例演示了format命令的不同用法和向量操作技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、命令输入

1、Cleaning Up

clear Clears variables from the workspace.
clc Clears the Command Window and moves the cursor to the upper left corner of the window.

2、format

>> format long
   Task 2 ✔
>> 13/6
ans =
   2.166666666666667
   Task 3 ✔
>> format bank
   Task 4 ✔
>> 13/6
ans =
          2.17
>> format short
>> 13/6
ans =
    2.1667
>> help format

在这里插入图片描述

3 导入、另存数据文件

在这里插入图片描述

4 获取帮助

You can enter

doc fcnName
to get information on any MATLAB function.

5 创建向量

5.1 Create a Row Vector

Use square brackets and separate the values using a comma or a space.
Example

a = [10 15 20 25]

a =
10 15 20 25
Create a Column Vector

Use square brackets and separate the values using a semi-colon.
Example

b = [2;3;5;7]

b =
2
3
5
7
Transpose a Vector

Use the transpose operator '.
Example

c = b’

c =
2 3 5 7
Create a Matrix

Use square brackets and enter values row-by-row. Separate values in a row using a comma or a space, and use a semicolon to start a new row.
Example

A = [1 3 5;2 4 6]

A =
1 3 5
2 4 6

5.2 Creating Evenly-Spaced Vectors

Suppose you want to create a vector containing every integer from 1 to 10. You’ll need to type every number from 1 through 10.

v = [1 2 3 4 5 6 7 8 9 10];

Now what if you want your vector to contain every integer from 1 to 25?

v = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25];

Creating long vectors by manually entering every value can be tedious. In this lesson, you’ll learn to create vectors containing evenly-spaced elements using more compact syntax that uses the colon operator (😃 and the function linspace.

5.3 冒号:操作符

在这里插入图片描述

5.4 Linsapce 行间距

在这里插入图片描述

6、串联阵列

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

7 阵列创建函数

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值