Professional Documents
Culture Documents
29/02/16 01:10 PM MATLAB Command Window 1 of 8
29/02/16 01:10 PM MATLAB Command Window 1 of 8
>> u=[1 2 3]
u =
1
>> w=[1;2;3]
w =
1
2
3
>> z=[1 2 3]% vectores columna
z =
1
>> length(u)
ans =
3
>> length(w)
ans =
3
>> [f,c]= size(u)
f =
1
c =
3
>> dimension=size(w)
1 of 8
29/02/16 01:10 PM
dimension =
3
>> ans=
ans=
|
Error: Expression or statement is incomplete or incorrect.
>> ans=3
ans =
3
>> ans=3
ans =
3
>> f=1
f =
1
>> c=1
c =
1
>> dimension= 3 1
dimension= 3 1
|
Error: Unexpected MATLAB expression.
>> dimension=
dimension=
|
Error: Expression or statement is incomplete or incorrect.
>> u+v
ans =
2
>> u.*v
2 of 8
29/02/16 01:10 PM
3 of 8
ans =
1
-3
>> n=100;
>> a=1:n;
>> S=sum(a)
S =
5050
>> a=1:10;
>> cs=cumsum(a)
cs =
1
>> a=3:3:5000;
>> s=sum(a)
s =
4165833
>> A=[1,2;3,4]
A =
1
10
15
21
28
36
45
55
29/02/16 01:10 PM
3
-2
-3
-4
>> A(:,1)
ans =
1
3
>> M=[A,B;B,A]
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
>> M41=M(1:3,2:4)
Undefined function 'M' for input arguments of type 'double'.
>> M=eye(4)
M =
1
0
0
0
0
1
0
0
>> N=zeros(3)
N =
0
0
1
0
0
0
0
1
4 of 8
29/02/16 01:10 PM
0
0
0
0
0
0
0
0
0
>> O=ones(2)
O =
1
1
1
1
>> P=rand(3,2)
P =
0.8147
0.9058
0.1270
0.9134
0.6324
0.0975
>> A+B
Error using +
Matrix dimensions must agree.
>> A(1,1)*B(1,1)+A(1,2)*B(2,1)
Index exceeds matrix dimensions.
>> A+B-B*A
Error using +
Matrix dimensions must agree.
>> sqrt(4)
ans =
2
>> sqrt(-4)
ans =
0.0000 + 2.0000i
>> abs(4)
ans =
4
>> abs(-4)
ans =
5 of 8
29/02/16 01:10 PM
6 of 8
4
>> abs(3+4*i)
ans =
5
>> exp(1)
ans =
2.7183
>> log(ans)
ans =
1
>> log10(10)
ans =
1
>> n=log(16384)/log(2)
n =
14
>> format long
>> e=4:14;
>> v=2.^e
v =
Columns 1 through 10
2048
16
Column 11
16384
>> S=sum(v)
S =
4096
32
8192
64
128
256
512
1024
29/02/16 01:10 PM
32752
>> v=
v=
|
Error: Expression or statement is incomplete or incorrect.
>> v= columns 1 through 6
v= columns 1 through 6
|
Error: Unexpected MATLAB expression.
>> sin(pi/2)
ans =
1
>> sin(90)
ans =
0.893996663600558
>> atan(1)*180/pi
ans =
45
>> atan2(1,1)*180/pi
ans =
45
>> atan2(-1,-1)*180/pi
ans =
-135
>> sinh(1)
ans =
1.175201193643801
>> (exp(1)-exp(-1))/2
7 of 8
29/02/16 01:10 PM
ans =
1.175201193643802
>> cosh(1)
ans =
1.543080634815244
>> (exp(1)+exp(-1))/2
ans =
1.543080634815244
>> tanh(1)
ans =
0.761594155955765
>> sinh(1)/cosh(1)
ans =
0.761594155955765
>> x=-1:0.01:1;
>> y=tanh(x);
>> plot(x,y)
>> function y=runge(x)
function y=runge(x)
|
Error: Function definitions are not permitted in this
context.
>> function y= runge(x)
function y= runge(x)
|
Error: Function definitions are not permitted in this
context.
>> function y = runge(x)
function y = runge(x)
|
Error: Function definitions are not permitted in this
context.
>> % funtion runge
>>
8 of 8