Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> who
- >> a=12.99
- a =
- 12.9900
- >> who
- Your variables are:
- a
- >> whos
- Name Size Bytes Class Attributes
- a 1x1 8 double
- >> A=[ 1 2 3; 4 5 6; 7 8 9]
- A =
- 1 2 3
- 4 5 6
- 7 8 9
- >> who
- Your variables are:
- A a
- >> whos
- Name Size Bytes Class Attributes
- A 3x3 72 double
- a 1x1 8 double
- >> B=[2 -1 3.5; -0.13 2.2; 3 0.5 34]
- Error using vertcat
- Dimensions of matrices being concatenated are not consistent.
- >> B=[2 -1 3.5; -0.13 -0.3 2.2; 3 0.5 34]
- B =
- 2.0000 -1.0000 3.5000
- -0.1300 -0.3000 2.2000
- 3.0000 0.5000 34.0000
- >>
- >> whos
- Name Size Bytes Class Attributes
- A 3x3 72 double
- B 3x3 72 double
- a 1x1 8 double
- >> P=[]
- P =
- []
- >> whos
- Name Size Bytes Class Attributes
- A 3x3 72 double
- B 3x3 72 double
- P 0x0 0 double
- a 1x1 8 double
- >> Suma = A + B
- Suma =
- 3.0000 1.0000 6.5000
- 3.8700 4.7000 8.2000
- 10.0000 8.5000 43.0000
- >> Suma A+B ;
- Error: "Suma" was previously used as a variable, conflicting with its use here as the name of a function or command.
- See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation for details.
- >> Roz A-B
- Undefined function 'Roz' for input arguments of type 'char'.
- >> Roz= A-B
- Roz =
- -1.0000 3.0000 -0.5000
- 4.1300 5.3000 3.8000
- 4.0000 7.5000 -25.0000
- >> A10=10*A
- A10 =
- 10 20 30
- 40 50 60
- 70 80 90
- >> AP=5+A
- AP =
- 6 7 8
- 9 10 11
- 12 13 14
- >> Mnoz=A*B
- Mnoz =
- 10.7400 -0.1000 109.9000
- 25.3500 -2.5000 229.0000
- 39.9600 -4.9000 348.1000
- >> Dziel = A/B
- Dziel =
- -0.4315 -4.5199 0.4251
- -0.4857 -13.2421 1.0833
- -0.5399 -21.9643 1.7415
- >> Dziel1 = A*inv(B)
- Dziel1 =
- -0.4315 -4.5199 0.4251
- -0.4857 -13.2421 1.0833
- -0.5399 -21.9643 1.7415
- >> T=Dziel - Dziel1
- T =
- 1.0e-14 *
- 0.0111 -0.0888 -0.0056
- 0.0111 0 0.0222
- 0.1221 -0.3553 0
- >> Nowa=A.*B
- Nowa =
- 2.0000 -2.0000 10.5000
- -0.5200 -1.5000 13.2000
- 21.0000 4.0000 306.0000
- >> // powstajaca macierznowa
- // powstajaca macierznowa
- |
- Error: Unexpected MATLAB operator.
- >> // skladniki iloczynu przechowywane sa w tej samej macierzy
- // skladniki iloczynu przechowywane sa w tej samej macierzy
- |
- Error: Unexpected MATLAB operator.
- >> pierwszy wyrazA bedzie mial numer 1.1, zawsze peirwszy wiersz druga kolumna
- Undefined function 'pierwszy' for input arguments of type 'char'.
- >> POT=A.^B
- POT =
- 1.0e+32 *
- 0.0000 0.0000 0.0000
- 0.0000 0.0000 0.0000
- 0.0000 0.0000 2.7813
- >> w podstawie a sa przechowywane wykladniki macierzy B
- Undefined function 'w' for input arguments of type 'char'.
- >> teraz manipulacja blokami danych
- Undefined function 'teraz' for input arguments of type 'char'.
- >> a
- a =
- 12.9900
- >> A
- A =
- 1 2 3
- 4 5 6
- 7 8 9
- >> B
- B =
- 2.0000 -1.0000 3.5000
- -0.1300 -0.3000 2.2000
- 3.0000 0.5000 34.0000
- >> chcemy utworzyc macierz 3x6 zeby A dolaczyc z prawej
- Undefined function 'chcemy' for input arguments of type 'char'.
- >> laczymy teraz tablice
- Undefined function 'laczymy' for input arguments of type 'char'.
- >> AB = [A, B]
- AB =
- 1.0000 2.0000 3.0000 2.0000 -1.0000 3.5000
- 4.0000 5.0000 6.0000 -0.1300 -0.3000 2.2000
- 7.0000 8.0000 9.0000 3.0000 0.5000 34.0000
- >> utworz nowa macierz w pierwszym wierzu a i drugim wierszu b
- Undefined function 'utworz' for input arguments of type 'char'.
- >> AB1 = [A; B]
- AB1 =
- 1.0000 2.0000 3.0000
- 4.0000 5.0000 6.0000
- 7.0000 8.0000 9.0000
- 2.0000 -1.0000 3.5000
- -0.1300 -0.3000 2.2000
- 3.0000 0.5000 34.0000
- >> whos
- Name Size Bytes Class Attributes
- A 3x3 72 double
- A10 3x3 72 double
- AB 3x6 144 double
- AB1 6x3 144 double
- AP 3x3 72 double
- B 3x3 72 double
- Dziel 3x3 72 double
- Dziel1 3x3 72 double
- Mnoz 3x3 72 double
- Nowa 3x3 72 double
- P 0x0 0 double
- POT 3x3 72 double
- Roz 3x3 72 double
- Suma 3x3 72 double
- T 3x3 72 double
- a 1x1 8 double
- >> ABB = [AB, B, A]
- ABB =
- 1.0000 2.0000 3.0000 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000 1.0000 2.0000 3.0000
- 4.0000 5.0000 6.0000 -0.1300 -0.3000 2.2000 -0.1300 -0.3000 2.2000 4.0000 5.0000 6.0000
- 7.0000 8.0000 9.0000 3.0000 0.5000 34.0000 3.0000 0.5000 34.0000 7.0000 8.0000 9.0000
- >> whos
- Name Size Bytes Class Attributes
- A 3x3 72 double
- A10 3x3 72 double
- AB 3x6 144 double
- AB1 6x3 144 double
- ABB 3x12 288 double
- AP 3x3 72 double
- B 3x3 72 double
- Dziel 3x3 72 double
- Dziel1 3x3 72 double
- Mnoz 3x3 72 double
- Nowa 3x3 72 double
- P 0x0 0 double
- POT 3x3 72 double
- Roz 3x3 72 double
- Suma 3x3 72 double
- T 3x3 72 double
- a 1x1 8 double
- >> size(ABB)
- ans =
- 3 12
- >> polecenie wyzej to sprawdzenie wielkosci tablicy
- Undefined function 'polecenie' for input arguments of type 'char'.
- >> AB2= [AB;B,B]
- AB2 =
- 1.0000 2.0000 3.0000 2.0000 -1.0000 3.5000
- 4.0000 5.0000 6.0000 -0.1300 -0.3000 2.2000
- 7.0000 8.0000 9.0000 3.0000 0.5000 34.0000
- 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000
- -0.1300 -0.3000 2.2000 -0.1300 -0.3000 2.2000
- 3.0000 0.5000 34.0000 3.0000 0.5000 34.0000
- >> AB3 = [A,A;B]
- Error using vertcat
- Dimensions of matrices being concatenated are not consistent.
- >> wyzej nie dziala bo niezgodne wymiary
- Undefined function 'wyzej' for input arguments of type 'char'.
- >> dana=AB(2,3)
- dana =
- 6
- >> 2*6+2
- ans =
- 14
- >> teraz tworzy sie ans czyli answer, nazwa domyslna zmiennej nieprzypisanej zadnej zmiennej
- Undefined function 'teraz' for input arguments of type 'char'.
- >> transponowanie macierzy
- Undefined function 'transponowanie' for input arguments of type 'char'.
- >> AT=A'
- AT =
- 1 4 7
- 2 5 8
- 3 6 9
- >> help clear
- clear Clear variables and functions from memory.
- clear removes all variables from the workspace.
- clear VARIABLES does the same thing.
- clear GLOBAL removes all global variables.
- clear FUNCTIONS removes all compiled MATLAB and MEX-functions.
- clear ALL removes all variables, globals, functions and MEX links.
- clear ALL at the command prompt also clears the base import list.
- clear IMPORT clears the base import list. It can only be issued at the
- command prompt. It cannot be used in a function.
- clear CLASSES is the same as clear ALL except that class definitions
- are also cleared. If any objects exist outside the workspace (say in
- userdata or persistent in a locked program file) a warning will be
- issued and the class definition will not be cleared. clear CLASSES must
- be used if the number or names of fields in a class are changed.
- clear JAVA is the same as clear ALL except that java classes on the
- dynamic java path (defined using JAVACLASSPATH) are also cleared.
- clear VAR1 VAR2 ... clears the variables specified. The wildcard
- character '*' can be used to clear variables that match a pattern. For
- instance, clear X* clears all the variables in the current workspace
- that start with X.
- clear -REGEXP PAT1 PAT2 can be used to match all patterns using regular
- expressions. This option only clears variables. For more information on
- using regular expressions, type "doc regexp" at the command prompt.
- If X is global, clear X removes X from the current workspace, but
- leaves it accessible to any functions declaring it global.
- clear GLOBAL X completely removes the global variable X.
- clear GLOBAL -REGEXP PAT removes global variables that match regular
- expression patterns.
- Note that to clear specific global variables, the GLOBAL option must
- come first. Otherwise, all global variables will be cleared.
- clear FUN clears the function specified. If FUN has been locked by
- MLOCK it will remain in memory. Use a partial path (see PARTIALPATH) to
- distinguish between different overloaded versions of FUN. For
- instance, 'clear inline/display' clears only the INLINE method for
- DISPLAY, leaving any other implementations in memory.
- clear ALL, clear FUN, or clear FUNCTIONS also have the side effect of
- removing debugging breakpoints and reinitializing persistent variables
- since the breakpoints for a function and persistent variables are
- cleared whenever the program file changes or is cleared.
- Use the functional form of clear, such as clear('name'), when the
- variable name or function name is stored in a string.
- Examples for pattern matching:
- clear a* % Clear variables starting with "a"
- clear -regexp ^b\d{3}$ % Clear variables starting with "b" and
- % followed by 3 digits
- clear -regexp \d % Clear variables containing any digits
- See also clearvars, who, whos, mlock, munlock, persistent, import.
- Reference page in Help browser
- doc clear
- >> diag(A)
- ans =
- 1
- 5
- 9
- >> czyli glowna przekatna
- Undefined function 'czyli' for input arguments of type 'char'.
- >> diag(AB)
- ans =
- 1
- 5
- 9
- >> det(A)
- ans =
- 6.6613e-16
- >> wyznacznik macierzy, proste
- Undefined function 'wyznacznik' for input arguments of type 'char'.
- >> poznajemy operator zakresu, czyli range operator
- Undefined function 'poznajemy' for input arguments of type 'char'.
- >> kiedy chcemy skopiowac fragment jakiejs wiekszej tablicy
- Undefined function 'kiedy' for input arguments of type 'char'.
- >> AB2=[ A A A; B B B]
- AB2 =
- 1.0000 2.0000 3.0000 1.0000 2.0000 3.0000 1.0000 2.0000 3.0000
- 4.0000 5.0000 6.0000 4.0000 5.0000 6.0000 4.0000 5.0000 6.0000
- 7.0000 8.0000 9.0000 7.0000 8.0000 9.0000 7.0000 8.0000 9.0000
- 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000
- -0.1300 -0.3000 2.2000 -0.1300 -0.3000 2.2000 -0.1300 -0.3000 2.2000
- 3.0000 0.5000 34.0000 3.0000 0.5000 34.0000 3.0000 0.5000 34.0000
- >> size(AB2)
- ans =
- 6 9
- >> Anowa = AB(2:5; 2:3)
- Anowa = AB(2:5; 2:3)
- |
- Error: Unbalanced or unexpected parenthesis or bracket.
- >> Anowa = AB(2:5,2:3)
- Index exceeds matrix dimensions.
- >> wiersz4 = AB2(4,1:9)
- wiersz4 =
- 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000
- >> wiersz41=AB2(4, :)
- wiersz41 =
- 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000 2.0000 -1.0000 3.5000
- >> kol2=AB@( : , 2)
- kol2=AB@( : , 2)
- |
- Error: Unbalanced or unexpected parenthesis or bracket.
- >> kol2=AB2(:,2)
- kol2 =
- 2.0000
- 5.0000
- 8.0000
- -1.0000
- -0.3000
- 0.5000
- >> kol2t=kol2'
- kol2t =
- 2.0000 5.0000 8.0000 -1.0000 -0.3000 0.5000
- >> A
- A =
- 1 2 3
- 4 5 6
- 7 8 9
- >> sum(A)
- ans =
- 12 15 18
- >> sum(A')
- ans =
- 6 15 24
- >> sum(A')'
- ans =
- 6
- 15
- 24
- >> wektory - ciagi liczbowe
- wektory - ciagi liczbowe
- |
- Error: Unexpected MATLAB expression.
- >> operator zakresu to dwukropek
- Undefined function 'operator' for input arguments of type 'char'.
- >> k=0:10
- k =
- 0 1 2 3 4 5 6 7 8 9 10
- >> k1=2:0.1:3.2
- k1 =
- Columns 1 through 12
- 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000
- Column 13
- 3.2000
- >> czyli zaczynamy od 2 z krokiem co 0.1 i do 3.2
- Undefined function 'czyli' for input arguments of type 'char'.
- >> ciagx=2:5:49
- ciagx =
- 2 7 12 17 22 27 32 37 42 47
- >> % (ogolnie: ciag = start :krok/przyrost: koncowa wartosc/koniec)
- >> cl=1:0.7:12
- cl =
- Columns 1 through 12
- 1.0000 1.7000 2.4000 3.1000 3.8000 4.5000 5.2000 5.9000 6.6000 7.3000 8.0000 8.7000
- Columns 13 through 16
- 9.4000 10.1000 10.8000 11.5000
- >> size(cl)
- ans =
- 1 16
- >> r=size(cl)
- r =
- 1 16
- >> size(r)
- ans =
- 1 2
- >> w=r(1,1)
- w =
- 1
- >> kol=r(1,2)
- kol =
- 16
- >> [w,k]=size(cl)
- w =
- 1
- k =
- 16
- >> w
- w =
- 1
- >> k
- k =
- 16
- >> dl=length(cl)
- dl =
- 16
- >> c2=1:-0.2:-1
- c2 =
- 1.0000 0.8000 0.6000 0.4000 0.2000 0 -0.2000 -0.4000 -0.6000 -0.8000 -1.0000
- >> c3=-1:-0.2:1
- c3 =
- Empty matrix: 1-by-0
- >> k=0:20
- k =
- Columns 1 through 20
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
- Column 21
- 20
- >> kpol=0.5*k
- kpol =
- Columns 1 through 12
- 0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000 5.5000
- Columns 13 through 21
- 6.0000 6.5000 7.0000 7.5000 8.0000 8.5000 9.0000 9.5000 10.0000
- >> kk=5+k
- kk =
- Columns 1 through 20
- 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
- Column 21
- 25
- >> pi
- ans =
- 3.1416
- >> i
- ans =
- 0.0000 + 1.0000i
- >> j
- ans =
- 0.0000 + 1.0000i
- >> %pi to taka predefiniowana stala, nie musimy dysponowac jej dokladna wartoscia
- >> e
- Undefined function or variable 'e'.
- >> %kiedy wpisujemy "i" to jednostka urojona, podobnie dziala "j"
- >> %matlab dziala na liczbach rzeczywistych i zespolonych
- >> pi=50
- pi =
- 50
- >> who
- Your variables are:
- A AB2 B Nowa Suma c2 dana kk kpol wiersz4
- A10 ABB Dziel P T c3 dl kol pi wiersz41
- AB AP Dziel1 POT a ciagx k kol2 r
- AB1 AT Mnoz Roz ans cl k1 kol2t w
- >> %po takiej operacji zmienna zablokuje nam dostep do predefiniowanej liczby pi
- >> %jak odzyskac dostep do liczby pi do jej normalnej wartosci?
- >> %who maskuje dostep do predefinoiwanej jednostki, jezeli w komendzie, poleceniu pojawi sie nazwa zmiennej to wtedy matlab rozpoczyna przeszukiwanie i jesli jej nie nzajdzie szuka
- >> mx=max(A)
- mx =
- 7 8 9
- >> mn=min(A)
- mn =
- 1 2 3
- >> mmm=max(mx)
- mmm =
- 9
- >> mmm=max(max(A))
- mmm =
- 9
- >> E=eye(4)
- E =
- 1 0 0 0
- 0 1 0 0
- 0 0 1 0
- 0 0 0 1
- >> %macierz jednostkowa
- >> E1=eye(4,7)
- E1 =
- 1 0 0 0 0 0 0
- 0 1 0 0 0 0 0
- 0 0 1 0 0 0 0
- 0 0 0 1 0 0 0
- >> E1=eye(6,3)
- E1 =
- 1 0 0
- 0 1 0
- 0 0 1
- 0 0 0
- 0 0 0
- 0 0 0
- >> %magic robi ze wszystkie sumy wyrazow w wierszach i kolumnach sa jednakowe
- >> M=magic(6)
- M =
- 35 1 6 26 19 24
- 3 32 7 21 23 25
- 31 9 2 22 27 20
- 8 28 33 17 10 15
- 30 5 34 12 14 16
- 4 36 29 13 18 11
- >> w1=sum(M)
- w1 =
- 111 111 111 111 111 111
- >> %sumowanie wartosci w kolumnach
- >> w2=sum(M')
- w2 =
- 111 111 111 111 111 111
- >> %sumowanie wartosci w wierszach
- >> J=ones(3,6)
- J =
- 1 1 1 1 1 1
- 1 1 1 1 1 1
- 1 1 1 1 1 1
- >> Z=zeros(4,5)
- Z =
- 0 0 0 0 0
- 0 0 0 0 0
- 0 0 0 0 0
- 0 0 0 0 0
- >> % stworzymy sobie kolejno wektor 4 zer a potem z 4 jedynek czy jakos tak
- >> Z=zeros(1,4)
- Z =
- 0 0 0 0
- >> J=ones(1,4)
- J =
- 1 1 1 1
- >> okres=[J,Z]
- okres =
- 1 1 1 1 0 0 0 0
- >> syg=[okres, okres, okres, okres, okres]
- syg =
- Columns 1 through 20
- 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
- Columns 21 through 40
- 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
- >> length(syg)
- ans =
- 40
- >> %uzywanie petli - macierz pusta
- >> sygnal =[]
- sygnal =
- []
- >> for i=1:10
- sygnal=[sygnal;okres]
- end
- sygnal =
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- sygnal =
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- 1 1 1 1 0 0 0 0
- >> help randn
- randn Normally distributed pseudorandom numbers.
- R = randn(N) returns an N-by-N matrix containing pseudorandom values drawn
- from the standard normal distribution. randn(M,N) or randn([M,N]) returns
- an M-by-N matrix. randn(M,N,P,...) or randn([M,N,P,...]) returns an
- M-by-N-by-P-by-... array. randn returns a scalar. randn(SIZE(A)) returns
- an array the same size as A.
- Note: The size inputs M, N, P, ... should be nonnegative integers.
- Negative integers are treated as 0.
- R = randn(..., 'double') or R = randn(..., 'single') returns an array of
- normal values of the specified class.
- The sequence of numbers produced by randn is determined by the settings of
- the uniform random number generator that underlies RAND, randn, and RANDI.
- randn uses one or more uniform random values to create each normal random
- value. Control that shared random number generator using RNG.
- Examples:
- Example 1: Generate values from a normal distribution with mean 1
- and standard deviation 2.
- r = 1 + 2.*randn(100,1);
- Example 2: Generate values from a bivariate normal distribution with
- specified mean vector and covariance matrix.
- mu = [1 2];
- Sigma = [1 .5; .5 2]; R = chol(Sigma);
- z = repmat(mu,100,1) + randn(100,2)*R;
- Example 3: Reset the random number generator used by RAND, RANDI, and
- randn to its default startup settings, so that randn produces the same
- random numbers as if you restarted MATLAB.
- rng('default');
- randn(1,5)
- Example 4: Save the settings for the random number generator used by
- RAND, RANDI, and randn, generate 5 values from randn, restore the
- settings, and repeat those values.
- s = rng
- z1 = randn(1,5)
- rng(s);
- z2 = randn(1,5) % z2 contains exactly the same values as z1
- Example 5: Reinitialize the random number generator used by RAND,
- RANDI, and randn with a seed based on the current time. randn will
- return different values each time you do this. NOTE: It is usually
- not necessary to do this more than once per MATLAB session.
- rng('shuffle');
- randn(1,5)
- See Updating Your Random Number Generator Syntax to use RNG to replace
- randn with the 'seed' or 'state' inputs.
- See also rand, randi, rng, RandStream, RandStream/randn
- Overloaded methods:
- RandStream/randn
- distributed/randn
- codistributor2dbc/randn
- codistributor1d/randn
- codistributed/randn
- gpuArray/randn
- Reference page in Help browser
- doc randn
- >> %funkcja randn zwraca probki o rozkladzie noramlnym, czyli gaussowaskim
- >> szum=randn(1,10)
- szum =
- 0.5377 1.8339 -2.2588 0.8622 0.3188 -1.3077 -0.4336 0.3426 3.5784 2.7694
- >> %sygnal losowy o rozkladzie gaussowskim
- >> szum_rown=rand(2,5)
- szum_rown =
- 0.1576 0.9572 0.8003 0.4218 0.7922
- 0.9706 0.4854 0.1419 0.9157 0.9595
- >> % wyzej - sygnal o rozkladzie rownomiernym
- >> %na przedziale ten sygnal jest 0 , 1
- >> srednia = mean(szum)
- srednia =
- 0.6243
- >> %wartosc srednia
- >> szum=randn(1,1000); srednia=mean(szum)
- srednia =
- -0.0460
- >> %cztery funkcje ktore dotycza zaokraglenie
- >> ceil(5.3)
- ans =
- 6
- >> %zawsdze w gore
- >> floor(3.8)
- ans =
- 3
- >> fix(6.7)
- ans =
- 6
- >> fix(-4.8)
- ans =
- -4
- >> %zawsze w kierunku zera - fix
- >> round(13.4)
- ans =
- 13
- >> %round zaokraglenie
- >> fix(2.7)
- ans =
- 2
- >> round(2.7)
- ans =
- 3
- >> %TABLICE ZNAKOWE
- >> txt1='Ulubiona ksiazka'
- txt1 =
- Ulubiona ksiazka
- >> txt2='Ala ma kota'
- txt2 =
- Ala ma kota
- >> tekst = [txt1, ':', txt2]
- tekst =
- Ulubiona ksiazka:Ala ma kota
- >> tekst = [txt1, ' : ', txt2]
- tekst =
- Ulubiona ksiazka : Ala ma kota
- >> %symulacja rzutu kostka
- >> rzut=rand(1,1)
- rzut =
- 0.5301
- >> rzut=6*rand(1,1)
- rzut =
- 1.6504
- >> rzut=floor(6*rand(1,1))
- rzut =
- 1
- >> rzut=floor(rand(1,1)) +1
- rzut =
- 1
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 2 5 6 1 4
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 1 5 6 1 6
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 1 5 5 4 6
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 6 4 1 2 2
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 1 1 4 6 3
- >> rzut = floor(6*rand(1,5)) +1
- rzut =
- 3 6 6 5 6
- >> %za kazdym nastepnym razem wywolanai tej funkcja sa inne wartosci
- >> %FUNKCJE TRYGONOMETRYCZNE
- >> A=3 %amplituda
- A =
- 3
- >> f=2 %czestotliwosc
- f =
- 2
- >> t=0:0.01:1 %wektor czasu
- t =
- Columns 1 through 12
- 0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100
- Columns 13 through 24
- 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300
- Columns 25 through 36
- 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 0.3200 0.3300 0.3400 0.3500
- Columns 37 through 48
- 0.3600 0.3700 0.3800 0.3900 0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700
- Columns 49 through 60
- 0.4800 0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 0.5600 0.5700 0.5800 0.5900
- Columns 61 through 72
- 0.6000 0.6100 0.6200 0.6300 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900 0.7000 0.7100
- Columns 73 through 84
- 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900 0.8000 0.8100 0.8200 0.8300
- Columns 85 through 96
- 0.8400 0.8500 0.8600 0.8700 0.8800 0.8900 0.9000 0.9100 0.9200 0.9300 0.9400 0.9500
- Columns 97 through 101
- 0.9600 0.9700 0.9800 0.9900 1.0000
- >> s=A*sin(2*pi*f*t) % sygnal
- s =
- Columns 1 through 12
- 0 2.7279 -2.2704 -0.8382 2.9681 -1.6321 -1.6097 2.9718 -0.8637 -2.2530 2.7388 -0.0266
- Columns 13 through 24
- -2.7167 2.2877 0.8127 -2.9641 1.6543 1.5872 -2.9753 0.8891 2.2353 -2.7496 0.0531 2.7054
- Columns 25 through 36
- -2.3048 -0.7871 2.9599 -1.6764 -1.5647 2.9786 -0.9144 -2.2175 2.7601 -0.0797 -2.6938 2.3217
- Columns 37 through 48
- 0.7615 -2.9554 1.6983 1.5419 -2.9817 0.9397 2.1996 -2.7704 0.1062 2.6820 -2.3384 -0.7358
- Columns 49 through 60
- 2.9508 -1.7201 -1.5191 2.9845 -0.9649 -2.1814 2.7805 -0.1327 -2.6700 2.3549 0.7100 -2.9459
- Columns 61 through 72
- 1.7418 1.4961 -2.9871 0.9900 2.1631 -2.7903 0.1593 2.6578 -2.3713 -0.6842 2.9407 -1.7634
- Columns 73 through 84
- -1.4731 2.9894 -1.0150 -2.1446 2.8000 -0.1858 -2.6454 2.3875 0.6583 -2.9354 1.7848 1.4499
- Columns 85 through 96
- -2.9915 1.0399 2.1260 -2.8094 0.2123 2.6327 -2.4035 -0.6323 2.9298 -1.8061 -1.4266 2.9934
- Columns 97 through 101
- -1.0648 -2.1072 2.8186 -0.2387 -2.6199
- >> plot(t,s)
- >> grid on
- >> %ZAPIS DO PLIKU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement