//----------------------//
// Zadania z MATLABA //
//----------------------//
----------------------------/
Zadania i Pytania kontrolne - wektory, macierze i struktury danych
----------------------------/
v=[100:-5:-100]
zad 1.1
----------------------------/
b=[cos((2:100)*pi)]
zad 1.2
----------------------------/
n=[0 ones(1,98) 0]
zad 1.3
----------------------------/
m=[(1:100).^3]
zad 1.4
----------------------------/
a=[3.^(1:100)]
zad 1.5
----------------------------/
s=[0 1 (2:100).^(1:99)]
zad 1.6
----------------------------/
s=[0 1 (2:100).^(-2:-1:-100)]
zad 1.7
----------------------------/
f=[1 1./sqrt(2:100)]
zad 1.8
----------------------------/
g=[1 sqrt(2:100)/2:100]
zad 1.9
----------------------------/
j=[1 (1:99)./sqrt(2:100)]
zad 1.10
----------------------------/
v=[0 -1 sqrt(2:100)./2:100]
zad 1.11
----------------------------/
v=[0 (1:99)./sqrt(100:-1:2) 100]
zad 1.12
----------------------------/
k=[1+i*(1:100)]
zad 1.13
----------------------------/
po=[0,pi pi./(2:100)]
zad 1 14
----------------------------/
v=[0 exp(-1:-1:-100)]
zad 1.15
----------------------------/
z=[-1./(10:-1:2) -1 0 1 1./(2:10)]
zad 1.16
----------------------------/
x=[exp(-20:-1) 0 exp(1:20)]
zad 1.17
----------------------------/
c=[10.^(-10:-1) 0 10.^(1:10)]
zad 1.18
----------------------------/
v(2:2:200)=1:100
zad 1.19
----------------------------/
A=round(10*rand(6,9)) //tworzy losową macierz o wymiarach 6x9
B=A([1,4],[3:6])
zad 1.20
----------------------------/
C=A([2:2:6] , :)
zad 1.21
----------------------------/
D=A(:,[9:-2:1])
zad 1.22
----------------------------/
E(1:2:5,:)= zeros(3,9)
zad 1.23
----------------------------/
F=[ones(1,11); ones(6,1) A ones(6,1); ones(1,11)]
zad 1.24
----------------------------/
[w k]=size(G) //sprawdza rozmiar macierzy G
H=[A(1,1),A(1,:),A(1,k);A(:,1), A A(:,k);A(w,1), A(w,:),A(w,k)]
zad 1.25
----------------------------/
W=[0 1; 2 3; 1 2]
E=[1;0;2]
>>W*E
??? Error using ==> mtimes
Inner matrix dimensions must agree. //błąd, bo wymiary macierzy się nie zgadzają
W'*E
ans =
2
5
W^2
??? Error using ==> mpower
Matrix must be square.
W.^2
ans =
0 1
4 9
1 4
W(:,2).*E
ans =
1
0
4
zad 1.26
----------------------------/
Q=[0 1; 2 3]
W=[1;3]
Q =
0 1
2 3
W =
1
3
Q*W
ans =
3
11
Q.*W
??? Error using ==> times
Matrix dimensions must agree.
Q^2
ans =
2 3
6 11
Q.^2
ans =
0 1
4 9
W^2
??? Error using ==> mpower
Matrix must be square.
W.^2
ans =
1
9
Q(:,2)./W
ans =
1
1
Q(1,:)*W
ans =
3
W./Q(:,2)
ans =
1
1
zad 1.27
----------------------------/
zad 1.28
----------------------------/
E=[1 2; 0 1 ; 2 3]
R=[1 1 ; 2 2 ; 3 3]
E =
1 2
0 1
2 3
R =
1 1
2 2
3 3
E.*R
ans =
1 2
0 2
6 9
E*R
??? Error using ==> mtimes
Inner matrix dimensions must agree.
E^2
??? Error using ==> mpower
Matrix must be square.
E.^2
ans =
1 4
0 1
4 9
E(1,:).\R(1,:)
ans =
1.0000 0.5000
zad 1.29
----------------------------/
T=[1 2;3 0]
Y=[1 1;2 2]
T =
1 2
3 0
Y =
1 1
2 2
T.*Y
ans =
1 2
6 0
T.^Y
ans =
1 2
9 0
zad 1.30
----------------------------/
T(4,4)=10
T =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 10
T(:,[3,1])=ones(4,2)*10
T =
10 0 10 0
10 0 10 0
10 0 10 0
10 0 10 10
zad 1.31
----------------------------/
Y= eye(4)
Y =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Y(2:3,[3,2])=ones(2)
Y =
1 0 0 0
0 1 1 0
0 1 1 0
0 0 0 1
zad 1.32
----------------------------/
U=10*ones(4)
U =
10 10 10 10
10 10 10 10
10 10 10 10
10 10 10 10
U([1 4],1:3:4)=eye(2)
U =
1 10 10 0
10 10 10 10
10 10 10 10
0 10 10 1
zad 1.33
----------------------------/
I(4,4)=2
I =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 2
I([1 3],1:3)=2*ones(2,3)
I =
2 2 2 0
0 0 0 0
2 2 2 0
0 0 0 2
zad 1.34
----------------------------/
U(4,4)=5
U =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 5
U([1,3],:) = 5*ones(2,4)
U =
5 5 5 5
0 0 0 0
5 5 5 5
0 0 0 5
zad 1.35
----------------------------/
Wyszukiwarka
Podobne podstrony:
zadanie matlabmatlab komendyMatLab KomendyMatlab zadania 3Matlab zadaniaMATLAB zestaw przykladowe zadaniaMatlab zadania 9Matlab zadania statystykaMatlab zadania 5Matlab zadania 4Matlab zadania 2Matlab zadania 6Zadania kolokwium z matlaba MSIBMatlab zadania różniczkowanie?łkowanieAnaliza Matematyczna 2 Zadaniawięcej podobnych podstron