matlab笔记(1)----基础

来源:互联网 发布:java 微信支付api 编辑:程序博客网 时间:2024/05/20 23:07
MATLAB操作桌面包括:
1:当前文件夹--是指MATLAB运行文件的工作文件夹。
2:命令窗口--用于输入MATLAB命令、函数、矩阵、表达式等信息,并显示除图形以外的所有计算结果,是MATLAB的主要交互窗口。
3: 工作空间窗口--用于存储各种变量和运算结果的内存空间。
4:命令历史窗口--记录已经运行过的命令、函数、表达式等信息,可以进行命令历史的查找、检查等工作,也对在该窗口中对命令历史进行复制、删除等操作。


常用的基础命令
(1) clc 擦去一页命令窗口,光标回屏幕左上角
(2) clear 从工作空间清除所有变量
(3) clf 清除图形窗口内容
(4) who 列出当前工作空间中的变量
(5) whos 列出当前工作空间中的变量及信息
(6)help 在线帮助总览
(7)help elfun 显示某类函数信息
(8)help round 显示具体函数的帮助信息


常用常见基础
(1)% 注释。
(2)ans 系统默认变量名。
(3)Ctrl+Q 键退出MATLAB(或者quit、exit命令退出)。
(4);数组间的行分隔符,用于指令尾时,表示不显示运行结果。
(5)[] 数组输入时用。
(6)空格 输入量与输入量的分隔符,数组行元素间的分隔符。
(7), 指令间的分隔符,其余作用同空格。
(8)...  起到连接两行的目的,也就是说,实际上是一个命令分开写而已






常用常数的值:
pi            3.1415926…….         
i             虚数单位              
j             虚数单位                    
NaN           空值


示例:
>> A=56/7-2+19*2+3^2   %输入,单击<Enter>键


A =


    53


示例:
>> 2*sin(pi/4)+3*cos(pi/2)   %pi代表π


ans =


    1.4142


示例:


>> who


Your variables are:


A    ans  


>> whos
  Name      Size            Bytes  Class     Attributes


  A         1x1                 8  double              
  ans       1x1                 8  double        


示例:
部分:
>> help
HELP topics:


matlab\general                 - General purpose commands.
matlab\ops                     - Operators and special characters.
matlab\lang                    - Programming language constructs.
matlab\elmat                   - Elementary matrices and matrix manipulation.
matlab\randfun                 - Random matrices and random streams.
matlab\elfun                   - Elementary math functions.
matlab\specfun                 - Specialized math functions.
matlab\matfun                  - Matrix functions - numerical linear algebra.
matlab\datafun                 - Data analysis and Fourier transforms.
matlab\polyfun                 - Interpolation and polynomials.
matlab\funfun                  - Function functions and ODE solvers.
>> help elfun    %elfun基础数学函数
  Elementary math functions.
 
  Trigonometric.
    sin         - Sine.
    sind        - Sine of argument in degrees.
    sinh        - Hyperbolic sine.
    asin        - Inverse sine.
    asind       - Inverse sine, result in degrees.    
>> help round  %显示具体函数信息,本例为round函数。
 ROUND  Round towards nearest integer.
    ROUND(X) rounds the elements of X to the nearest integers.
 
    See also floor, ceil, fix.


    Overloaded methods:
       codistributed/round
       quantizer/round


    Reference page in Help browser
       doc round  


数据操作


1、input函数
调用格式为:变量名=input('提示信息’,'s');   
示例:
>> a = input('what is your name? \n','s')   % \n 表示换行输入,参数s表示允许输入字符串
what is your name? 
luo


a =


luo
2、disp函数
调用格式:disp (输出项)
示例:
>> disp(a)
luo


3、pause函数
调用格式:pause(n)  % n是一个常数,表示延迟多少秒


4、save命令
将工作间中的变量存入磁盘
5、load命令
将磁盘里的数据读入工作间


示例:
>> a=2;
>> b=4;
>> c=6;
>> save mydatel
>> save mydat2 a b
>> clear
>> whos
>> 
>> load mydat2 a
>> whos
  Name      Size            Bytes  Class     Attributes


  a         1x1                 8  double              



原创粉丝点击