matlab生成向量的指令,MATLAB学习-基础篇

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

620db8034f982e8dba1408b5e0bbb98a.png

3 导入、另存数据文件

1bef1d80d711ab2e528e5604435049d9.png

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 (

标签:10,format,基础,学习,every,MATLAB,using,Example,row

来源: https://blog.csdn.net/flyhelloword/article/details/113741774

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值