cd aa1819/calcolo_numerico1/ ls 1+2 ans = 3 2*3 ans = 6 1/3 ans = 0.3333 1.23 ans = 1.2300 1/3 ans = 0.3333 format long e 1/3 ans = 3.333333333333333e-01 format 1/3 ans = 0.3333 % format controlla esclusivamente la visualizzazione sqrt(2) ans = 1.4142 sin(pi/2) ans = 1 pi ans = 3.1416 exp(1)ù exp(1)ù ↑ {Error: The input character is not valid in MATLAB statements or expressions. } exp(1) ans = 2.7183 log10(10) ans = 1 log2(2) ans = 1 log(exp(1)) ans = 1 2+3*4 ans = 14 (2+3)*4 ans = 20 2(2+3) 2(2+3) ↑ {Error: Unbalanced or unexpected parenthesis or bracket. } 2*(2 + 3) ans = 10 a=1 a = 1 b=1/3 b = 0.3333 a+b ans = 1.3333 c=sqrt(2) c = 1.4142 whos Name Size Bytes Class Attributes a 1x1 8 double ans 1x1 8 double b 1x1 8 double c 1x1 8 double ans ans = 1.3333 2+3 ans = 5 ans=2 ans = 2 3+4 ans = 7 ans ans = 7 sqrt(-1) ans = 0.0000 + 1.0000i whos Name Size Bytes Class Attributes a 1x1 8 double ans 1x1 16 double complex b 1x1 8 double c 1x1 8 double matrice = [1,2,3;4,5,6;7,8,9] matrice = 1 2 3 4 5 6 7 8 9 matrice=[1,2;3] {Dimensions of matrices being concatenated are not consistent. } matrice=[[1;4;7],[4;5;6],[7;8;9]] matrice = 1 4 7 4 5 8 7 6 9 matrice=[[1;4;7],[4;5;6],[7;8]] {Dimensions of matrices being concatenated are not consistent. } matrice=[[1;4;7],[4;5;6],[7;8;9]] matrice = 1 4 7 4 5 8 7 6 9 whos Name Size Bytes Class Attributes a 1x1 8 double ans 1x1 16 double complex b 1x1 8 double c 1x1 8 double matrice 3x3 72 double matrice matrice = 1 4 7 4 5 8 7 6 9 : : ↑ {Error: Unexpected MATLAB operator. } : : ↑ {Error: Unexpected MATLAB operator. } matrice(1,;) matrice(1,;) ↑ {Error: Unbalanced or unexpected parenthesis or bracket. } matrice(1,:) ans = 1 4 7 matrice(:,3) ans = 7 8 9 riga2=matrice(2,:) riga2 = 4 5 8 1:10 ans = 1 2 3 4 5 6 7 8 9 10 matrice(3,1:2) ans = 7 6 matrice(3,[1,3]) ans = 7 9 v=[1;2;3] v = 1 2 3 matrice matrice = 1 4 7 4 5 8 7 6 9 matrice*v ans = 30 38 46 w=[4;5;6] w = 4 5 6 v v = 1 2 3 w' ans = 4 5 6 w'*v ans = 32 v'*w ans = 32 z=v.*w z = 4 10 18 v*w {Error using * Inner matrix dimensions must agree. } v*w' ans = 4 5 6 8 10 12 12 15 18 w' ans = 4 5 6 v v = 1 2 3 v'*w ans = 32 v*w' ans = 4 5 6 8 10 12 12 15 18 matrice2=ones(3) matrice2 = 1 1 1 1 1 1 1 1 1 matrice matrice = 1 4 7 4 5 8 7 6 9 matrice*matrice2 ans = 12 12 12 17 17 17 22 22 22 matrice.*matrice2 ans = 1 4 7 4 5 8 7 6 9 matrice^2 ans = 66 66 102 80 89 140 94 112 178 matrice*matrice ans = 66 66 102 80 89 140 94 112 178 matrice.^2 ans = 1 16 49 16 25 64 49 36 81 floor(2.9) ans = 2 ceil(2.9) ans = 3 ls primoscript.m primoscript a = 2 b = 4 primoscript b = 4 a a = 2 ls primafunction.m primoscript.m help primafunction function [c] = primafunction(a,b) Calcola la somma di a e b. primafunction(1,5) ans = 6 ls dectobin.m primafunction.m primoscript.m edit dectobin mod(5,2) ans = 1 5/2 ans = 2.5000 fliplr([1,2,3]) ans = 3 2 1 numero=34.27 numero = 34.2700 numero-floor(numero) ans = 0.2700 format long e numero-floor(numero) ans = 2.700000000000031e-01 34.27-34 ans = 2.700000000000031e-01 dectobin(125,-3) ans = 0 [d,c]=dectobin(125,-3) d = 0 c = 0 0 1 [d,c]=dectobin(3427,-2) d = 1 0 0 0 1 0 c = Columns 1 through 12 0 1 0 0 0 1 0 1 0 0 0 1 Columns 13 through 24 1 1 1 0 1 0 1 1 1 0 0 0 Columns 25 through 36 0 1 0 1 0 0 0 1 1 1 1 0 Columns 37 through 48 1 0 1 1 1 0 0 0 0 1 0 1 Columns 49 through 51 0 0 1 [d,c]=dectobin(1,-1) d = 0 c = Columns 1 through 12 0 0 0 1 1 0 0 1 1 0 0 1 Columns 13 through 24 1 0 0 1 1 0 0 1 1 0 0 1 Columns 25 through 36 1 0 0 1 1 0 0 1 1 0 0 1 Columns 37 through 48 1 0 0 1 1 0 0 1 1 0 0 1 Columns 49 through 55 1 0 0 1 1 0 1 diary off