Matlab basic operation:

>> 5+6

ans =

11

>> 3*4

ans =

12

>> 2^6

ans =

64

>> 1==2

ans =

0

>> 1~=2

ans =

1

>> 1&&0

ans =

0

>> 1||0

ans =

1

>> xor(1,0)

ans =

1

>> xor(1,1)

ans =

0

>> who

您的变量为:

ans

>> whos

Name      Size            Bytes  Class      Attributes

ans       1x1                 1  logical

>> a=3;

>> b='hi'

b =

hi

>> c=(3>=1)

c =

1

>> a=pi;

>> a

a =

3.1416

>> disp(a);

3.1416

>> disp(sprintf('2 decimals: %0.2f',a))

2 decimals: 3.14

>> disp(sprintf('6 decimals: %0.6f',a))

6 decimals: 3.141593

>> format long

>> a

a =

3.141592653589793

>> format short

>> a

a =

3.1416

>> A=[1 2;3 4;5 6]

A =

1     2

3     4

5     6

>> A=[1 2;

3 4;

5 6]

A =

1     2

3     4

5     6

>> v=[1 2 3]

v =

1     2     3

>> v=[1;2;3]

v =

1

2

3

>> v=1:0.1:2

v =

1.0000    1.1000    1.2000    1.3000    1.4000    1.5000    1.6000    1.7000    1.8000    1.9000    2.0000

>> v=1:0.3:2

v =

1.0000    1.3000    1.6000    1.9000

>> v=1:7

v =

1     2     3     4     5     6     7

>> ones(2,3)

ans =

1     1     1

1     1     1

>> C=2*ones(2,3)

C =

2     2     2

2     2     2

>> w=zeros(3,1)

w =

0

0

0

>> rand(3,3)

ans =

0.8147    0.9134    0.2785

0.9058    0.6324    0.5469

0.1270    0.0975    0.9575

>> rand(3,3)

ans =

0.9649    0.9572    0.1419

0.1576    0.4854    0.4218

0.9706    0.8003    0.9157

>> rand(3,3)

ans =

0.7922    0.0357    0.6787

0.9595    0.8491    0.7577

0.6557    0.9340    0.7431

%rand 平均分布(0~1)

%randn 标准正态分布

>> randn(3,3)

ans =

-0.2256    0.0326    1.5442

1.1174    0.5525    0.0859

-1.0891    1.1006   -1.4916

>> w=-6+sqrt(10)*(randn(1,10000))

>> hist(w)

>> hist(w,50)

>> I=eye(4)

I =

1     0     0     0

0     1     0     0

0     0     1     0

0     0     0     1

>> A

A =

1     2

3     4

5     6

>> size(A)

ans =

3     2

>> sz=size(A)

sz =

3     2

>> size(sz)

ans =

1                  2

>> size(A,1)

ans =

3

>> size(A,2)

ans =

2

>> v

v =

1     2     3     4     5     6     7

>> length(v)

ans =

7

>> length(A)   %longer dimension

ans =

3

>> v=w(1:10)

v =

-8.3474   -9.3570    1.4328   -7.9467   -3.6344   -6.6085   -3.1900   -8.4187  -10.4344  -10.4979

>> save hello.mat v

>> clear

>> load hello.mat

>> v

v =

-8.3474   -9.3570    1.4328   -7.9467   -3.6344   -6.6085   -3.1900   -8.4187  -10.4344  -10.4979

>> save hello.txt v –ascii

>> A=[1 2;3 4; 5 6]

A =

1     2

3     4

5     6

>> A(3,2)

ans =

6

>> A(2,:)

ans =

3     4

>> A(:,2)

ans =

2

4

6

>> A([1 3],:)

ans =

1     2

5     6

>> A(:,1)

ans =

1

3

5

>> A(:,2)

ans =

2

4

6

>> A(:,2)=[10; 11; 12]

A =

1    10

3    11

5    12

>> A=[A,[100;101;102]]  %append another vector to right

A =

1    10   100

3    11   101

5    12   102

>> A(:)  % put all the elements into a single vector

ans =

1

3

5

10

11

12

100

101

102

A =

1     2

3     4

5     6

>> B=[7 8;9 10;11 12]

B =

7     8

9    10

11    12

>> C=[A B]

C =

1     2     7     8

3     4     9    10

5     6    11    12

>> A

A =

1     2

3     4

5     6

>> B

B =

7     8

9    10

11    12

>> C=[2 5 ;6 7]

C =

2     5

6     7

>> A*C

ans =

14    19

30    43

46    67

>> A.*B

ans =

7    16

27    40

55    72

>> v=[1;2;3]

v =

1

2

3

>> 1./v

ans =

1.0000

0.5000

0.3333

>> 1./A

ans =

1.0000    0.5000

0.3333    0.2500

0.2000    0.1667

>> log(v)

ans =

0

0.6931

1.0986

>> exp(v)

ans =

2.7183

7.3891

20.0855

>> abs([-1;2;-3])

ans =

1

2

3

>> v+ones(length(v),1)

ans =

2

3

4

>> v+1

ans =

2

3

4

>> a=[1 15 2 0.5]

a =

1.0000   15.0000    2.0000    0.5000

>> max(a)

ans =

15

>> [val,ind]=max(a)   %max valus and it’s index

val =

15

ind =

2

>> max(A)

ans =

5     6

>> a<3

ans =

1     0     1     1

>> find(a<3)

ans =

1     3     4

>> [r,c]=find(A>7)

r =

1

3

c =

1

2

>> a

a =

1.0000   15.0000    2.0000    0.5000

>> sum(a)

ans =

18.5000

>> prod(a)  %product of a

ans =

15

>> floor(a)

ans =

1    15     2     0

>> ceil(a)

ans =

1    15     2     1

>> rand(3)

ans =

0.8099    0.6218    0.4893

0.6378    0.4146    0.0938

0.8981    0.6476    0.6373

>> rand(3)

ans =

0.9503    0.5915    0.1566

0.4764    0.2253    0.7743

0.6028    0.6684    0.2131

>> max(rand(3),rand(3))

ans =

0.1691    0.8745    0.3584

0.7258    0.6258    0.8875

0.3631    0.2581    0.9005

>> A=magic(3)

A =

8     1     6

3     5     7

4     9     2

>> max(A,[],1)

ans =

8     9     7

>> max(A,[],2)

ans =

8

7

9

>> max(A)

ans =

8     9     7

>> max(max(A))

ans =

9

>> max(A(:))

ans =

9

>> sum(A,1)

ans =

15    15    15

>> sum(A,2)

ans =

15

15

15

>> A.*eye(3)

ans =

8     0     0

0     5     0

0     0     2

>> sum(sum(A.*eye(3)))

ans =

15

>> flipud(eye(3))

ans =

0     0     1

0     1     0

1     0     0

>> A=magic(3)

A =

8     1     6

3     5     7

4     9     2

>> temp=pinv(A)

temp =

0.1472   -0.1444    0.0639

-0.0611    0.0222    0.1056

-0.0194    0.1889   -0.1028

>> temp*A

ans =

1.0000    0.0000   -0.0000

-0.0000    1.0000    0.0000

0.0000    0.0000    1.0000

>>t=[0 :0.1 :0.98] ;

>>y1=sin(2*pi*4*t) ;

>>plot(t,y1)

>> y2=cos(2*pi*4*t);

>> plot(t,y2)

>> plot(t,y1)

>> hold on

>> plot(t,y2)

>> xlabel('time')

>> ylabel('value')

>> legend('sin','cos')

>> title('plot1')

>> print -dpng 'plot1.png'  %save the diagram into a png format picture

>> figure(1);plot(t,y1);

>> figure(2);plot(t,y2);

>> subplot(1,2,1);

>> subplot(1,2,1);

>> plot(t,y1)

>> subplot(1,2,2);

>> plot(t,y2)

>> axis([0.5 1 -1 1])

>> clf

>> A=magic(5)

A =

17    24     1     8    15

23     5     7    14    16

4     6    13    20    22

10    12    19    21     3

11    18    25     2     9

>> imagesc(A)

>> imagesc(A),colorbar,colormap gray;

>> imagesc(magic(16)),colorbar,colormap gray;

>> addpath('E:\machine learning\machine-learning-ex1\machine-learning-ex1\ex1')

matlab basic operation command的更多相关文章

  1. 【MongoDB】The basic operation of Index in MongoDB

    In the past four blogs, we attached importance to the index, including description and comparison wi ...

  2. 15 Basic ‘ls’ Command Examples in Linux

    FROM: http://www.tecmint.com/15-basic-ls-command-examples-in-linux/ ls command is one of the most fr ...

  3. MatLab GUI Use Command for Debug 界面调试的一些方法

    在MatLab的GUI界面编程,我们在调试的时候需要打印出一些变量,那么介绍下我用到的两种调试方法: 第一种,使用弹出对话框来打印变量,要注意的是打印的东西必须是string类型的,所以其他类型的变量 ...

  4. 13 Basic Cat Command Examples in Linux(转) Linux中cat命令的13中基本用法

    Cat (串联) 命令是Linux/Unix开源系统中比较常用的一个命令.我们可以通过Cat命令创建一个或多个文件,查看文件内容,串联文件并将内容输出到终端设备或新的文件当中,这篇文章我们将会以实例的 ...

  5. 13 Basic Cat Command Examples in Linux

    FROM: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ The cat (short for “concatenate ...

  6. Basic Operation about Linux

    1. 永久开启/关闭防火墙 在linux中防火墙是一个名叫iptables的工具 开启: chkconfig iptables on 关闭: chkconfig iptables off 即时生效,重 ...

  7. Javascript Basic Operation Extraction

    1.  logic operation : '&&' and '||'  .For this two logic operations,its' results are inconcl ...

  8. Basic linux command

    1. useradd  解释:添加新用户,在/etc/password文件中添加一行记录. 参数: -g    用于添加账户时指定该账户的私有组,如果不指定-g参数,useradd命令会自动创建与该用 ...

  9. mysql basic operation,mysql总结

    mysql> select * from wifi_data where dev_id like "0023-AABBCCCCBBAA" ; 1.显示数据库列表.show d ...

随机推荐

  1. javascript的缓动效果

    这部分对原先的缓动函数进行抽象化,并结合缓动公式进行强化.成品的效果非常惊人逆天.走过路过不要错过. 好了,打诨到此为止.普通的加速减速是难以让人满意的,为了实现弹簧等让人眼花缭乱的效果必须动用缓动公 ...

  2. RDIFramework.NET框架Web中datagrid与treegrid控件自动生成右键菜单与列标题右键菜单

    在实际应用中常可以看到数据展示控件有右键菜单的功能,对应的列标题也可以右键弹出快捷菜单设置指定列的显示与隐藏等功能.在我们的RDIFramework.NET Web框架中,只要是使用了EasyUI的D ...

  3. GPS部标监控平台的架构设计(八)-基于WCF的平台数据通信设计

    总体来讲,GPS部标平台的软件开发是一个对网络通信和应用程序之间通信的技术应用密集型的开发工作,也是有一定设计技术含量的工作. 1.设计通信接口 在设计的时候,根据职责划分,拆分成不同的应用子系统,对 ...

  4. C# 连接Oracle ,免安装客户端

    在.NET平台下开发Oracle应用的小伙伴们肯定都知道一方面做Oracle开发和实施相比SqlServer要安装Oracle客户端(XCopy.自己提取相关文件也有一定复杂性),另一方面相比JAVA ...

  5. PostgreSQL 磁盘使用大小监控

    表大小信息 postgres=# SELECT *, pg_size_pretty(total_bytes) AS totalpostgres-# , pg_size_pretty(index_byt ...

  6. Windows 服务为宿主的WCF服务,详细图解。

    废话不多说,直接进入主题: 1.打开vs2010新建项目,选择Windows服务. 2.选中WindowsService右击,添加WCF服务. 3.添加成功后,为下图.将接口类ITestService ...

  7. OpenERP 使用与开发笔记(一)

    一直关注OpenERP,但一直未真正使用.最近一些数据想规范管理,免得使和EXCEL与WORD等到处找,所以想到OpenERP的自定义功能比较好,就再次找来相关资料重新拾掇起来.在这过程中,发现了许多 ...

  8. WebForm 内置对象2

    Session: 与Cookies相比 相同点:每一台电脑访问服务器,都会是独立的一套session,key值都一样,但是内容都是不一样的 以上所有内容,都跟cookies一样 不同点: 1.Sess ...

  9. Coursera台大机器学习课程笔记5 -- Theory of Generalization

    本章思路: 根据之前的总结,如果M很大,那么无论假设泛化能力差的概率多小,都无法忽略,所以问题转化为证明M不大,然后上章将其转化为证明成长函数:mh(N)为多项式级别.直接证明似乎很困难,本章继续利用 ...

  10. 华盛顿大学 Programming Languages

    表达式三要素: 语法,类型和计算值.