You are on page 1of 7

B=[1 2 3 4];

B*B
??? Error using ==> mtimes
Inner matrix dimensions must agree.
B*B'
ans =
30
B.*B
ans =
1

16

16

B.^2
ans =
1

A=ones(3);
C=[A zeros(3,2);ones(2,3) eye(2,2)]
C =
1
1
1
1
1

1
1
1
1
1

1
1
1
1
1

0
0
0
1
0

0
0
0
0
1

edit
fschange('C:\MATLAB701\work\Hilbert.m');
clear('C:\MATLAB701\work\Hilbert.m');
fschange('C:\MATLAB701\work\Hilbert.m');
clear('C:\MATLAB701\work\Hilbert.m');
Hilbert
H =
1.0000
0.5000
0.3333
0.2500
0.2000

0.5000
0.3333
0.2500
0.2000
0.1667

0.3333
0.2500
0.2000
0.1667
0.1429

prod(B)
ans =
24
B
B =
1

0.2500
0.2000
0.1667
0.1429
0.1250

max(B)
ans =
4
medium(B)
??? Undefined command/function 'medium'.
median(B)
ans =
2.5000
mean(B)
ans =
2.5000
B
B =
1

323

443

c=[1 2 3 4 5]
c =
1

median(c)
ans =
3
c=[100 22 2 323 443]
c =
100

22

median(c)
ans =
100
max(A)
ans =
1
max(max(A))

ans =
1
max(B)
ans =
4
max(c)
ans =
443
c=[1 2 3 4;5 6 7 8;1 23 4 5]
c =
1
5
1

2
6
23

3
7
4

4
8
5

23

max(c)
ans =
5

D=5:-1:1;
x=[0.0:0.1:2.0]'
x =
0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000
1.1000
1.2000
1.3000
1.4000
1.5000
1.6000
1.7000
1.8000
1.9000
2.0000
y=x.^2
y =

0
0.0100
0.0400
0.0900
0.1600
0.2500
0.3600
0.4900
0.6400
0.8100
1.0000
1.2100
1.4400
1.6900
1.9600
2.2500
2.5600
2.8900
3.2400
3.6100
4.0000
fschange('C:\MATLAB701\work\statistika.m');
clear('C:\MATLAB701\work\statistika.m');
clc
B
B =
1

statistika(B)
ans =
2.5000
[srednja,devijacija]=statistika(B)
srednja =
2.5000
devijacija =
1.2910
mean(B)
ans =
2.5000
std(B)
ans =
1.2910

clc
clear all
x=1:1:360;
y=sin(x);
comet(x,y)
plot(x,y)
y=sin(x/360*2*pi);
comet(x,y)
comet(x,y)
comet(x,y)
y=sin(x/(360*2*pi));
comet(x,y)
y=sin(x/360*2*pi);
x=0.0:0.1:2*pi;
y=sin(x);
comet(x,y)
comet(x,y)
clc
clear all
x=1:10;
y=[2 3 4 6 6 7 8 10 10 11];
X=[x ones(1)]
X =
1

10

10

x=X(1:10)
x =
1

x=x';
X=[x ones(1)]
??? Error using ==> horzcat
All matrices on a row in the bracketed expression must have the
same number of rows.
X=[x ones(10)]
X =
1
2
3
4
5
6
7
8
9
10
X=X(:,1)
X =
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

2
3
4
5
6
7
8
9
10
x
x =
1
2
3
4
5
6
7
8
9
10
X=[x,ones(1,10)]
??? Error using ==> horzcat
All matrices on a row in the bracketed expression must have the
same number of rows.
X=[x,ones(10,1)]
X =
1
2
3
4
5
6
7
8
9
10

1
1
1
1
1
1
1
1
1
1

Y=y';
s=inv(X'*X)*X'*Y
s =
1.0121
1.1333
plot(x,y)
plot(x,y,'+')
yy=s(1)*x+s(2);
plot(x,yy)
hold on
plot(x,y)
plot(x,y,'+')

hold on
plot(x,yy,'+')
plot(x,yy)
builtin('exit')

You might also like