matlab简单测试

这个MATLAB测试涵盖了基本的算术运算、变量赋值、三角函数、错误处理、帮助查询、数组创建、矩阵操作等内容。通过示例展示了如何进行乘除、加减、求余、对数、指数、取整、矩阵乘法等操作,并演示了如何使用输入、保存等功能。

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

octave:1> 548*50/25+29
ans =  1125
octave:2> a=548*50/25+29
a =  1125
octave:3> 2*sin(pi/4)+3cos(pi/2)
parse error:

  syntax error

>>> 2*sin(pi/4)+3cos(pi/2)
                   ^

octave:3> 2*sin(pi/4)+3*cos(pi/2)
ans =  1.4142
octave:4> help

  For help with individual commands and functions type

    help NAME

  (replace NAME with the name of the command or function you would
  like to learn more about).

  For a more detailed introduction to GNU Octave, please consult the
  manual.  To read the manual from the prompt type

    doc

  GNU Octave is supported and developed by its user community.
  For more information visit http://www.octave.org.

octave:5> look image
error: 'look' undefined near line 1 column 1
octave:5> lookfor image
!!! OUT OF TIME !!!

octave:5> lookfor
error: 'str' undefined near line 51 column 16
error: called from
    lookfor at line 51 column 3
error: evaluating argument list element number 1
error: called from
    lookfor at line 51 column 3
octave:5> a=cos(3.14)
a = -1.00000
octave:6> b=log(2.71828)
b =  1.00000
octave:7> c=exp(3.14)
c =  23.104
octave:8> d=fix(3.14)
d =  3
octave:9> c=ceil(3.14)
c =  4
octave:10> a=input("how many apples?\n",'s')
how many apples?
> s
a = s
octave:11> save
error: Invalid call to save.  Correct usage is:

 -- Command: save file
 -- Command: save options file
 -- Command: save options file V1 V2 ...
 -- Command: save options file -struct STRUCT F1 F2 ...
 -- Command: save '"-"' V1 V2 ...
 -- Built-in Function: S = save ('"-"' V1 V2 ...)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:11> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        a           1x1                          1  char
        ans         1x1                          8  double
        b           1x1                          8  double
        c           1x1                          8  double
        d           1x1                          8  double

Total is 5 elements using 33 bytes

octave:12> A=[3,2,1;33,22,11;333,222,111]
A =

     3     2     1
    33    22    11
   333   222   111

octave:13> B=[1 5 6]
B =

   1   5   6

octave:14> B=[1.5 5.0 6.1]
B =

   1.5000   5.0000   6.1000

octave:15> B=[1.5 5.0 6.1;1.0 -0.2 6.1;1.50 5 0.1;]
B =

   1.50000   5.00000   6.10000
   1.00000  -0.20000   6.10000
   1.50000   5.00000   0.10000

octave:16> A=1:2:60
A =

 Columns 1 through 16:

    1    3    5    7    9   11   13   15   17   19   21   23   25   27   29   31

 Columns 17 through 30:

   33   35   37   39   41   43   45   47   49   51   53   55   57   59

octave:17> A=[]
A = [](0x0)
octave:18> D=eye(5,6)
D =

Diagonal Matrix

   1   0   0   0   0   0
   0   1   0   0   0   0
   0   0   1   0   0   0
   0   0   0   1   0   0
   0   0   0   0   1   0

octave:19> C=5*ones(5)
C =

   5   5   5   5   5
   5   5   5   5   5
   5   5   5   5   5
   5   5   5   5   5
   5   5   5   5   5

octave:20> D=rand(6,9)
D =

 Columns 1 through 6:

   6.5572e-01   9.2002e-01   8.1475e-01   8.5271e-01   5.2211e-01   8.3316e-01
   4.8280e-01   9.9417e-01   6.2795e-01   8.6272e-01   2.3857e-01   8.7467e-02
   3.6472e-01   9.3043e-01   6.6981e-01   5.1275e-02   7.5949e-02   1.6994e-01
   9.4070e-02   6.5081e-01   2.6269e-01   1.9776e-01   7.7455e-01   6.8932e-02
   7.9348e-01   1.9945e-01   3.1718e-01   2.5419e-01   2.4984e-01   4.2278e-01
   7.2581e-01   3.1895e-01   7.7928e-01   9.3547e-01   8.6062e-01   5.1202e-01

 Columns 7 through 9:

   8.7936e-01   4.7200e-01   6.3722e-01
   9.8219e-01   7.4398e-01   4.2243e-01
   9.7408e-01   1.5397e-01   2.0348e-01
   9.7394e-01   5.3640e-01   5.0706e-01
   6.3841e-01   3.0152e-01   6.7846e-01
   8.7917e-01   5.4378e-01   1.9328e-04

octave:21> E=A+5
E = [](0x0)
octave:22> E=B+5
E =

    6.5000   10.0000   11.1000
    6.0000    4.8000   11.1000
    6.5000   10.0000    5.1000

octave:23> A=1:2:60
A =

 Columns 1 through 16:

    1    3    5    7    9   11   13   15   17   19   21   23   25   27   29   31

 Columns 17 through 30:

   33   35   37   39   41   43   45   47   49   51   53   55   57   59

octave:24> F=A*4
F =

 Columns 1 through 13:

     4    12    20    28    36    44    52    60    68    76    84    92   100

 Columns 14 through 26:

   108   116   124   132   140   148   156   164   172   180   188   196   204

 Columns 27 through 30:

   212   220   228   236

octave:25> m=[1 2;3 4]
m =

   1   2
   3   4

octave:26> n=[5 6;7 8]
n =

   5   6
   7   8

octave:27> J=m*n
J =

   19   22
   43   50

octave:28> K=A\B
error: operator \: nonconformant arguments (op1 is 1x30, op2 is 3x3)
octave:28> K=m\n
K =

  -3  -4
   4   5

NOTICE: Due to inactivity, your session will expire in five minutes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值