h=[0.01,0.02,0.03] h = 0.0100 0.0200 0.0300 x=[0,0.01,0.02,0.035,0.04,0.06] x = Columns 1 through 4 0 0.0100 0.0200 0.0350 Columns 5 through 6 0.0400 0.0600 h=x(2:6)-x(1:5) h = Columns 1 through 4 0.0100 0.0100 0.0150 0.0050 Column 5 0.0200 h=diff(x) h = Columns 1 through 4 0.0100 0.0100 0.0150 0.0050 Column 5 0.0200 1./h ans = Columns 1 through 4 100.0000 100.0000 66.6667 200.0000 Column 5 50.0000 1./(h(1:4)+1./h(2:5) ??? 1./(h(1:4)+1./h(2:5) | Error: Expression or statement is incorrect--possibly unbalanced (, {, or [. 1./h(1:4)+1./h(2:5) ans = 200.0000 166.6667 266.6667 250.0000 d=1./h(1:4)+1./h(2:5) d = 200.0000 166.6667 266.6667 250.0000 d=[1/h(1),1./h(1:4)+1./h(2:5),1/h(5)] d = Columns 1 through 4 100.0000 200.0000 166.6667 266.6667 Columns 5 through 6 250.0000 50.0000 diag(d) ans = Columns 1 through 4 100.0000 0 0 0 0 200.0000 0 0 0 0 166.6667 0 0 0 0 266.6667 0 0 0 0 0 0 0 0 Columns 5 through 6 0 0 0 0 0 0 0 0 250.0000 0 0 50.0000 spdiags(d,0,6,6) ??? Index exceeds matrix dimensions. Error in ==> spdiags at 114 a((len(k)+1):len(k+1),:) = [i i+d(k) B(i+(m>=n)*d(k),k)]; d=[1/h(1),1./h(1:4)+1./h(2:5),1/h(5)]'; spdiags(d,0,6,6) ans = (1,1) 100.0000 (2,2) 200.0000 (3,3) 166.6667 (4,4) 266.6667 (5,5) 250.0000 (6,6) 50.0000 a=[1;2;3;4] a = 1 2 3 4 b=[5,6,7,8]; c=[9;10;11;12]; b=b'; spdiags([a,b,c],[-1,0,1],4,4) ans = (1,1) 5 (2,1) 1 (1,2) 10 (2,2) 6 (3,2) 2 (2,3) 11 (3,3) 7 (4,3) 3 (3,4) 12 (4,4) 8 A=spdiags([a,b,c],[-1,0,1],4,4); full(A) ans = 5 10 0 0 1 6 11 0 0 2 7 12 0 0 3 8 uiopen('/home/accounts/personale/clrmrc90/aa1112/equazioni_differenziali/fourier.m', true); i ans = 0 + 1.0000i for i=1:10 disp('ciao') end ciao ciao ciao ciao ciao ciao ciao ciao ciao ciao i i = 10 1i ans = 0 + 1.0000i 2i ans = 0 + 2.0000i % Modify expression to add input arguments. % Example: % a = [1 2 3; 4 5 6]; % foo(a); fourier x x = -3.1416 -3.0925 -3.0434 -2.9943 -2.9452 -2.8962 -2.8471 -2.7980 -2.7489 -2.6998 -2.6507 -2.6016 -2.5525 -2.5035 -2.4544 -2.4053 -2.3562 -2.3071 -2.2580 -2.2089 -2.1598 -2.1108 -2.0617 -2.0126 -1.9635 -1.9144 -1.8653 -1.8162 -1.7671 -1.7181 -1.6690 -1.6199 -1.5708 -1.5217 -1.4726 -1.4235 -1.3744 -1.3254 -1.2763 -1.2272 -1.1781 -1.1290 -1.0799 -1.0308 -0.9817 -0.9327 -0.8836 -0.8345 -0.7854 -0.7363 -0.6872 -0.6381 -0.5890 -0.5400 -0.4909 -0.4418 -0.3927 -0.3436 -0.2945 -0.2454 -0.1963 -0.1473 -0.0982 -0.0491 0 0.0491 0.0982 0.1473 0.1963 0.2454 0.2945 0.3436 0.3927 0.4418 0.4909 0.5400 0.5890 0.6381 0.6872 0.7363 0.7854 0.8345 0.8836 0.9327 0.9817 1.0308 1.0799 1.1290 1.1781 1.2272 1.2763 1.3254 1.3744 1.4235 1.4726 1.5217 1.5708 1.6199 1.6690 1.7181 1.7671 1.8162 1.8653 1.9144 1.9635 2.0126 2.0617 2.1108 2.1598 2.2089 2.2580 2.3071 2.3562 2.4053 2.4544 2.5035 2.5525 2.6016 2.6507 2.6998 2.7489 2.7980 2.8471 2.8962 2.9452 2.9943 3.0434 3.0925 plot(x,1./(sin(x)+2)) plot(x,1./(sin(x)+2)) fourier % Modify expression to add input arguments. % Example: % a = [1 2 3; 4 5 6]; % foo(a); fourier diary off