SHARE
TWEET

Scilab, cald function

SilLAwNeD Oct 16th, 2018 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [d] = cald(T, y)
  2.     exec('**/rich.sci', -1)
  3.  
  4.     tol = 1e-12
  5.  
  6.     n = size(y, 1)
  7.     a = zeros(n, 1)
  8.     b = zeros(n, 1)
  9.     c = zeros(n, 1)
  10.     d = zeros(n, 1)
  11.     u = zeros(n, 1)
  12.    
  13.     h = zeros(n, 1)
  14.     // vecteur l pour contenir la différence y(i+1)-y(i)
  15.     l = zeros(n, 1)
  16.    
  17.     h = T(2:n) - T(1:n-1)
  18.     l(1:n-1) = y(2:n) - y(1:n-1) // l(n) = 0 car de toute façon c(n) = 0
  19.    
  20.     for i = 1:n-1
  21.         if (abs(h(i)) < tol)then
  22.             error("h(i) trop petit")
  23.         end
  24.         // a(1) = 0
  25.         a(i+1) = 1 / h(i)
  26.         // c(n) = 0
  27.         c(i) = 1 / h(i)
  28.     end
  29.    
  30.     b = 2 * a(1:n) + 2 * c(1:n)
  31.     u(1) = l(1) .* c(1) .* c(1)
  32.     u(2:n) = l(1:n-1) .* (a(2:n).*a(2:n)) + l(2:n) .* (c(2:n).*c(2:n))
  33.    
  34.     d = rich(a, b, c, u)
  35.    
  36. endfunction
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top