Você está na página 1de 9

Matrix manipulations

Change column b =magic(4) a = b(:,[1 3 2 4]) sort([3+4i, 4+3i])


ans = 4.0000 + 3.0000i 3.0000 + 4.0000i

angle(3+4i)
ans = 0.9273

angle(4+3i)
ans = 0.6435

Floating point numbers have finite range of roughly 10e-308 to 10e+308 eps- floating point relative precision e = 2e-52 realmin smallest floating point no. 2e1022 realmax smallest floating point no. 2e+1022

Saving variable in .dat file


>>A = [1 2 3; 4 5 6; 7 8 9] >> save mat_A_dat >> A >> clear A >> load mat_A_dat >> A

Deleting row and column


>> A = magic(3) >> X=A >> X(:,2)=[ ] Building tables
>> n = (0:9) >> pow = [n n.^2 2.^n]

Format short g >> x = (1:0.1:2)'; >>logs = [x log10(x)]

MATLAB uses column oriented analysis. >> D = [25 50 75; 75 60 38; 50 50 60] >> D(:,1) is say for subject1 and so on >> mu = mean(D) >> sigma = std(D) >> X= [2.1 1.7 1.6 1.5 NaN 1.9 1.8 1.5 5.1 1.8 1.4 2.2 1.6 1.8] >> X = X(isfinite(X)) 5.1 is outline, remove elements of more than three standard deviations from the mean >> X = X(abs(X-mean(X))<=3*std(X))

Make non-prime numbers Zero >> A(~isprime(A)) = 0 >> A = [1 2 3; 4 5 6;7 8 9] >> k = find(isprime(A))'

Format function
>> x = [4/3 1.2348e-6] FORMAT may be used to switch between different output display formats of all float variables as follows: FORMAT SHORT Scaled fixed point format with 5 digits. FORMAT LONG Scaled fixed point format with 15 digits for double and 7 digits for single. FORMAT SHORT E Floating point format with 5 digits. FORMAT LONG E Floating point format with 15 digits for double and 7 digits for single. FORMAT SHORT G Best of fixed or floating point format with 5 digits. FORMAT LONG G Best of fixed or floating point format with 15 digits for double and 7 digits for single.

Format function cont..


FORMAT HEX Hexadecimal format. FORMAT + The symbols +, - and blank are printed for positive, negative and zero elements. Imaginary parts are ignored. FORMAT BANK Fixed format for dollars and cents. FORMAT RAT Approximation by ratio of small integers. FORMAT COMPACT Suppresses extra line-feeds. FORMAT LOOSE Puts the extra line-feeds back in.

Você também pode gostar