%slCharacterEncoding('UTF-8') 
%slCharacterEncoding('US-ASCII') 
slCharacterEncoding('Windows-1252') 
% LABORATORIUM 1         MATLAB       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% Zad. 1. Utwórz zmienn¹ a o wartoœci 3 tak aby wartoœæ bêd¹ca wynikiem nie by³a wyœwietlana 
% na ekranie. Oblicz jej pierwiastek . Oblicz wartoœæ funkcji sin dla zmiennej a 
% wynik zapisz do zmiennej b i wyœwietl na ekranie. 
%Oblicz wartoœæ cos 60stopni                             
%»  a=3;        » sqrt(a)    » b=sin(a)    »cos(pi/3)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad. 2. Oblicz wartoœæ wyra¿enia arctg(log(ln(4(3+2))))       
%» atan(log10(log(4*(3+2))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.3  Usuñ zmienn¹ a  z pamiêci a  nastêpnie usuñ  wszystkie zmienne z pamiêci  
% » clear a      » clear  all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.4  Oblicz z2=z1/(4-2i)  dla z1=3+4j , modu³ i sprzê¿enie liczby z1  
% » z1=3+4j  »z2=z1/(4-2i)  »abs(z1)   » conj(z1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.5 Oblicz modu³ i sprzê¿enie wyra¿enia z1*z2 dla  z2=z1/(8-2i)2  dla z1=2+12j   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.6 Utwórz wektor x= [-1.7,-0.3,3.2,5.8,8.0] zaokr¹glij liczby w górê, w dó³, przez obciêcie, 
% do najbli¿szej liczby ca³kowitej      
%»  ceil(x)   » floor(x)   » fix(x)   » round(x)   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.7 Oblicz wartoœæ bezwzglêdn¹ , wyœwietl tylko elementy 2,3,4,   
% podaj d³ugoœæ wektora
%  » abs(x)        » x(2:4)         »  length(x) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.8  Przedstaw wektor y=[1/3,1.3,6e-6] 
% w ró¿nych formatach: short, short e, long, long e, rat, bank, long g
% » format  short   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.9 Wykonaj dzia³ania  : 1/0 oraz 0/0   
% co wyra¿aj¹ otrzymane oznaczenia?       
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.10. Narysuj wykres y=3*x+7 dla x=-1:0.1:1 
% » x=[-1:0.1:1];    » y=3*x;   »plot(x,y)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                                                    1  2   3   1]
% Zad.12 Utwórz macierz 2-wierszow¹: pierwszy wiersz od 1 do 10 
%  drugi wiersz od 2 do 20 (z krokiem 2)   » A=[1:10;   2:2:20]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.13. Utwórz macierz D buduj¹c j¹ ze zdefiniowanych macierzy A, B i C
% » A=[1  4  1; 2   0   1];   » B=[3   1;   4   1];  
% »  C=[1   2   2   0   1;   2   4   7   1   0];   
% »  D=[A B;   C]
% Zaproponuj budowê podanej macierzy D z 4 innych macierzy
% J= [1 4  2 1;   2  0 1 6;  3  6  8  9 ];   
% Wyœwietl macierz H utworzon¹ wy³¹cznie z nastêpuj¹cych elementów macierzy J
% kolumny od 1 do 3 oraz wiersze od 2 do 4        
% » A(1:3,2:4)
% Podaj procedurê wyœwietlenia macierzy o elementach G=[2 1; 1 6] utworzonej z macierzy J? 
% Wyœwietl J jako wektor:     » J(:) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.14. Utwórz dowolne macierze A i B o wymiarach 5x5. 
% Wykonaj operacjê podstawiania: zast¹p 2,4 i 5 kolumnê macierzy A trzema 
% pierwszymi kolumnami macierzy B     
% » A(:,[ 2 4 5 ]) = B(:,1:3)    
% Zast¹p wiersze 1 i 4 macierzy A wierszami 2 i 5 macierzy B.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.15. Utwórz kwadratow¹ macierz jednostkow¹ A o wymiarze 3x3.     
% »A=eye(3) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.16. Utwórz macierz A o wymiarze 2x3 wype³nionej jedynkami.     
% »A=ones(2,3) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.17. Utwórz macierz A o wymiarze 3x2 wype³nionej zerami.  
% »A=zeros(3,2) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.18. Utwórz macierz losow¹ macierz kwadratow¹ 4x4   
% »A=magic(4) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.19. Utwórz macierz losow¹ K 10x15 o elementach z przedzia³u od 0 do 1  
% nastêpnie utwórz macierz jednostkow¹  Z o rozmiarach macierzy K      
% » rand (2,3)      » eye(size(K))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.20. Utwórz dowoln¹ macierz C. Podaj wartoœci maksymalne i minimalne 
% oraz oblicz wartoœæ œredni¹ i sumê ka¿dej kolumny dla macierzy C.    
% » max(C)    »min (C)   »mean(A)   »sum(A) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.21.Wyœwietl macierz C na ekranie
% » C         lub       »  disp(C) 
% Przypisz zmiennej d liczbê wierszy macierzy C  
% » n=size(A,1)    zaœ s liczbê kolumn 
% » s=size(A,2)    
% okreœl rozmiar macierzy  C  »[n,m]=size(C)       
% podaj wartoœæ elementu C23   » C(2,3)     
% podaj wartoœci elementów na diagonali macierzy C    » diag(C)   
% usuñ drugi wiersz z macierzy » C(2,:)=[]     
% Usuñ dwie pierwsze kolumny z macierzy C  » C(:,1:2)=[]     
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.22. Utwórz dwie dowolne macierze A i B nastêpnie oblicz ich sumê, 
% ró¿nicê oraz dodaj do macierzy A liczbê 2, sprawdŸ czy elementy macierzy A i B
% s¹ sobie równe, a mo¿e mniejsze równe          
% » A+B   » A-B   » A+2   » A==B     » A<=B
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Zad.23. Utwórz dwie dowolne macierze 2x2 A i B nastêpnie oblicz ich iloczyn, 
% wymnó¿ razy 2 macierz A, wykonaj dzielenie lewostronne X=A\B, prawostronne X=A/B,
% wykonaj transpozycjê macierzy B, oblicz macierz odwrotn¹ do 
% » A*B    » A*2    »X=A\B    »X=A/B  » B’   » inv(A)
% Zad.24. Zdefiniuj wektor [2 4 2] i oblicz sumê kwadratów elementów tego wektora  
% » C=[2 4 2]’   » C’*C
% Zad.25. Zdefiniuj macierze D=[5 -6 2; -2 4 1] E=[5 2 2; -1 -2 1] 
% wykonaj mno¿enie, dzielenie i potêgowanie tablicowe  
% » D.*E    » D./E       » D.^2  

