% Bisogna salvare il file midpointc.m nella propria cartella di lavoro: % http://www.dm.unibo.it/~achilles/calc/Programmi_CS4a/midpointc.m 1> help midpointc `midpointc' is a function from the file C:\Documents and Settings\rudiger.achilles\desktop\midpointc.m MIDPOINTC Formula composita del punto medio. IMP = MIDPOINTC(A,B,M,FUN) calcola una approssimazione dell'integrale della funzione tramite la formula composita del punto medio (su M intervalli equispaziati). FUN e' una function che riceve in ingresso un vettore x e restituisce un vettore reale. FUN puo' essere una inline function, una anonymous function o una function definita in un M-file. IMP = MIDPOINT(A,B,M,FUN,P1,P2,...) passa alla function FUN i parametri opzionali P1,P2,... come FUN(X,P1,P2,...). Additional help for built-in functions and operators is available in the on-line version of the manual. Use the command `doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 2> f = inline('x.^2') f = f(x) = x.^2 3> midpointc(0, 1, 1, f) ans = 0.25000 4> midpointc(0, 1, 10, f) ans = 0.33250 5> midpointc(0, 1, 15, f) ans = 0.33296 6> midpointc(0, 1, 20, f) ans = 0.33312 7> midpointc(0, 1, 40, f) ans = 0.33328 8> midpointc(0, 1, 80, f) ans = 0.33332 9> edit midpointc.m 10> midpointc(0, 1, 1, f) ans = 0.25000 11> midpointc(0, 1, 80, f) ans = 0.33332 12> edit midpointc.m 13> midpointc(0, 1, 1, f) ans = 0.25000 14> midpointc(0, 1, 80, f) ans = 0.33332 15> quit