Header Ads

Header ADS

Basic of MATLAB Command 02




##3
>>ones(3)
ans =   1     1     1
             1     1     1
             1     1     1
>>zeros(2,5)
ans =
     0     0     0     0     0
     0     0     0     0     0
>> size(G)
ans =
     3     4
>> ones(size(G))
ans =
     1     1     1     1
     1     1     1     1
     1     1     1     1
>>eye(4)
ans =
     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1
>>eye(2,4)
ans =
     1     0     0     0
     0     1     0     0
>>eye(4,2)
ans =0
>>rand(3)
ans =
    0.8147    0.9134    0.2785
    0.9058    0.6324    0.5469
    0.1270    0.0975    0.9575
>>rand(1,5)
ans =    0.9649    0.1576    0.9706    0.9572    0.4854
>> B=eye(3)
B =
     1     0     0
     0     1     0
     0     0     1
>> rand(size(B))
ans =
    0.8003    0.9157    0.6557
    0.1419    0.7922    0.0357
    0.4218    0.9595    0.8491
>>randn(2)
ans =
    1.6302    1.0347
    0.4889    0.7269
>> A=1:4
A = 1     2     3     4
>>diag(A)
ans =
    1     0     0     0
     0     2     0     0
     0     0     3     0
     0     0     0     4
>>diag(A,1)
ans =
     0     1     0     0     0
     0     0     2     0     0
     0     0     0     3     0
     0     0     0     0     4
     0     0     0     0     0
>>diag(a,-2)
ans =
    0     0     0     0     0     0     0
     0     0     0     0     0     0     0
     1     0     0     0     0     0     0
     0     2     0     0     0     0     0
     0     0     3     0     0     0     0
     0     0     0     4     0     0     0
     0     0     0     0     5     0     0
>> D=pi
D =3.1416
>> D*ones(3,4)
ans = 3.1416    3.1416    3.1416    3.1416
           3.1416    3.1416    3.1416    3.1416
           3.1416    3.1416    3.1416    3.1416
>>D+zeros(3,4)
ans =3.1416    3.1416    3.1416    3.1416
          3.1416    3.1416    3.1416    3.1416
          3.1416    3.1416    3.1416    3.1416

 we know about how to use MATLAB and how to command work at MATLAB and we learn about some function of MATLAB like value of pi,X,Y,ones and zeros also many more.When we do this lab we have to be careful about writing command code because if we write the wrong command code we will not get the right value of function.It is the basic of MATLAB. How to use MATLAB software and how to write command code where the result will shown in MATLAB.

No comments

Powered by Blogger.