MATLAB指令窗操作入门学习笔记

1、简单计算器的使用

 %1、简单计算机的使用
a=(55+5*(7.5-0.5))/2^3
%2、简单数组的输入
A=[1 2;3 4;5 6]
%3、数组分行输入
B=[1,2
   3,4
   5,6]

a =

   11.2500


A =

     1     2
     3     4
     5     6


B =

     1     2
     3     4
     5     6

2、MATLAB中的预定义变量

在这里插入图片描述

3、工作空间与变量管理

通常用以下三个指令进行变量管理:
1、clear指令删除变量
2、who查看工作空间的变量名
3、whos了解变量的具体信息

clear
>> X1=[0.2,1.11,3];
Y1=[1,2,3;4,5,6];
m=77;
n=0.5;
>> who

您的变量为:

X1  Y1  m   n   

>> whos
  Name      Size            Bytes  Class     Attributes

  X1        1x3                24  double              
  Y1        2x3                48  double              
  m         1x1                 8  double              
  n         1x1                 8  double           

4、常用的数字显示格式指令

在这里插入图片描述

a=215/3

>> format short e;a

a =

   7.1667e+01

>> format long e;a

a =

     7.166666666666667e+01

>> format short g;a

a =

       71.667

>> format long g;a

a =

          71.6666666666667

>> format hex;a

a =

   4051eaaaaaaaaaab

>> format bank;a

a =

         71.67

>> format +;a

a =

+

>> format rat;a

a =

     215/3     

5、常见的操作键

在这里插入图片描述

6、MATLAB常见的标点符号功能

需要注意的是:输入指令时,一般要在英文状态下输入。
请添加图片描述

请添加图片描述

7、在线帮助的使用

常用的两种在线帮助指令
1、help
2、lookfor

help format
 format Set output format.
    format with no inputs sets the output format to the default appropriate
    for the class of the variable. For float variables, the default is
    format SHORT.
 
    format does not affect how MATLAB computations are done. Computations
    on float variables, namely single or double, are done in appropriate
    floating point precision, no matter how those variables are displayed. 
    Computations on integer variables are done natively in integer. Integer
    variables are always displayed to the appropriate number of digits for
    the class, for example, 3 digits to display the INT8 range -128:127.
    format SHORT and LONG do not affect the display of integer variables.
 
    format may be used to switch between different output display formats
    of all float variables as follows:
      format SHORT     Scaled fixed point format with 5 digits.
      format LONG      Scaled fixed point format with 15 digits for double
                       and 7 digits for single.
      format SHORTE    Floating point format with 5 digits.
      format LONGE     Floating point format with 15 digits for double and
                       7 digits for single.
      format SHORTG    Best of fixed or floating point format with 5 
                       digits.
      format LONGG     Best of fixed or floating point format with 15 
                       digits for double and 7 digits for single.
      format SHORTENG  Engineering format that has at least 5 digits
                       and a power that is a multiple of three
      format LONGENG   Engineering format that has exactly 16 significant
                       digits and a power that is a multiple of three.
 
    format may be used to switch between different output display formats
    of all numeric variables as follows:
      format HEX     Hexadecimal format.
      format +       The symbols +, - and blank are printed 
                     for positive, negative and zero elements.
                     Imaginary parts are ignored.
      format BANK    Fixed format for dollars and cents.
      format RAT     Approximation by ratio of small integers.  Numbers
                     with a large numerator or large denominator are
                     replaced by *.
 
    format may be used to affect the spacing in the display of all
    variables as follows:
      format COMPACT Suppresses extra line-feeds.
      format LOOSE   Puts the extra line-feeds back in.
 
    Example:
       format short, pi, single(pi)
    displays both double and single pi with 5 digits as 3.1416 while
       format long, pi, single(pi)
    displays pi as 3.141592653589793 and single(pi) as 3.1415927.
 
       format, intmax('uint64'), realmax
    shows these values as 18446744073709551615 and 1.7977e+308 while
       format hex, intmax('uint64'), realmax
    shows them as ffffffffffffffff and 7fefffffffffffff respectively.
    The HEX display corresponds to the internal representation of the value
    and is not the same as the hexadecimal notation in the C programming
    language.
 
    See also disp, display, isnumeric, isfloat, isinteger.

    format 的参考页
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值