ls 20190311.txt 20190506.txt dectobin.m miafunzione.m polinomio1.m 2019-03-18.txt bintodec.m figtree.txt miafunzione.m~ polinomio1.m~ 2019-03-25.txt bisezione.m horner.m newton.m primafunction.m 20190401.txt bisezione.m~ lup0_kij.m newton.m~ primoscript.m 20190408.txt bs.m lup0_kij.m~ polinomio0.m radice.m 20190429.txt bs.m~ megp0.m polinomio0.m~ xi=rand(4,1) xi = 0.8147 0.9058 0.1270 0.9134 n=3 n = 3 [xi.^n,xi.^(n-1),xi.^(n-2),ones(4,1)] ans = 0.5408 0.6638 0.8147 1.0000 0.7432 0.8205 0.9058 1.0000 0.0020 0.0161 0.1270 1.0000 0.7620 0.8343 0.9134 1.0000 y=rand(4,1) y = 0.6324 0.0975 0.2785 0.5469 a=[xi.^n,xi.^(n-1),xi.^(n-2),ones(4,1)]\y a = 1.0e+03 * 0.8499 -1.5783 0.8211 -0.0803 xi xi = 0.8147 0.9058 0.1270 0.9134 [xi,xi,xi,xi] ans = 0.8147 0.8147 0.8147 0.8147 0.9058 0.9058 0.9058 0.9058 0.1270 0.1270 0.1270 0.1270 0.9134 0.9134 0.9134 0.9134 repmat(xi,1,n+1) ans = 0.8147 0.8147 0.8147 0.8147 0.9058 0.9058 0.9058 0.9058 0.1270 0.1270 0.1270 0.1270 0.9134 0.9134 0.9134 0.9134 3:-1:0 ans = 3 2 1 0 repmat(3:-1:0,n+1,1) ans = 3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 repmat(xi,1,n+1).^repmat(n:-1:0,n+1,1) ans = 0.5408 0.6638 0.8147 1.0000 0.7432 0.8205 0.9058 1.0000 0.0020 0.0161 0.1270 1.0000 0.7620 0.8343 0.9134 1.0000 vander(xi) ans = 0.5408 0.6638 0.8147 1.0000 0.7432 0.8205 0.9058 1.0000 0.0020 0.0161 0.1270 1.0000 0.7620 0.8343 0.9134 1.0000 i==j ans = 1 i ans = 0.0000 + 1.0000i j ans = 0.0000 + 1.0000i 1i ans = 0.0000 + 1.0000i i=3 i = 3 i i = 3 1i=3 1i=3 ↑ {Error: The expression to the left of the equals sign is not a valid target for an assignment. } 1i ans = 0.0000 + 1.0000i j=4 j = 4 i==j ans = 0 i i = 3 xi xi = 0.8147 0.9058 0.1270 0.9134 Li(1,xi(1),xi) ans = 1 Li(1,xi(2),xi) ans = 0 Li(1,xi(3),xi) ans = 0 Li(1,xi(4),xi) ans = 0 Li(2,xi(1),xi) ans = 0 Li(2,xi(2),xi) ans = 1 Li(2,xi(),xi) ans = 0 1 0 0 Li(2,xi(3),xi) ans = 0 Li(2,xi(4),xi) ans = 0 Li(2,xi,xi) ans = 0 1 0 0 Li(3,xi,xi) ans = 0 0 1 0 Li(4,xi,xi) ans = 0 0 0 1 Li(4,rand(10,1),xi) ans = 10.4233 12.6382 25.5918 14.4825 10.3259 84.3434 1.7439 13.0162 95.2963 1.3465 Li(4,rand(2,2),xi) ans = 2.8916 35.7269 11.0002 -105.1522 sin(rand(2,3)) ans = 0.7507 0.6278 0.6766 0.8040 0.6873 0.3822 Li(4,rand(2,3),xi) ans = 35.8058 21.3650 86.1887 35.5149 -110.6577 -90.7479 runge = @(x) 1./(1+x.^2); x=linspace(-5,5,101); plot(x,runge(x)) n=2 n = 2 xi=linspace(-5,5,n+1)' xi = -5 0 5 xi=[xi,runge(xi)] xi = -5.0000 0.0385 0 1.0000 5.0000 0.0385 V=vander(xi(:,1)) V = 25 -5 1 0 0 1 25 5 1 a=V\xi(:,2) a = -0.0385 0 1.0000 plot(x,runge(x),x,polyval(a,x)) plot(x,runge(x),x,intpolyval(x, xi)) figure plot(x,runge(x),x,intpolyval(x, xi)) diary off