euler1
 
 
% [y,x]=euler(f,a,y,n)
function [y,x]=euler(f,a,y,n)
 
 
h=(a(2)-a(1))/(n)
x=linspace(a(1),a(2),n+1);
yy=zeros(length(x),1);
 
yy(1)=y;
%f=strrep(f,'y','yy');
 
for i=1:n
      yy(i+1)=yy(i)+h*(-yy(i));
end
 
y=yy
x=x
 
----------------------------------------
heun
 
% [y,x]=heun(f,a,y,n,e)
function [y,x]=heun(f,a,y,n,e)
  if (nargin < 5), e = 1E-10, end;
  h = (a(end)-a(1))/n;
  x = a(1);
  y = y(:);
  yy = zeros(length(y),n+1);
  % robni pogoji
  yy(:,1) = y;
  % racunamo po korakih
  for i=2:n+1
    fx = eval(f);
    fx = fx(:);
    const_y = yy(:,i-1) + h/2 .* fx;
    x = x + h;
    y = yy(:,i-1);
    for j=1:20
      fx = eval(f);
      fx = fx(:);
      new_y = const_y + h/2 .* fx;
      if (abs(1 -y./new_y) < e), break, end;
      y = new_y;
    end
    yy(:,i) = y;
  end
  % vrnemo rezultate
  x = a(1):h:a(2);
  y = yy;
retur
 
-------------------------------------------------------------------------
modeuler
 
% [y,x]=modeuler(f,a,y,n)
function [y,x]=euler(f,a,y,n)
 
 
h=(a(2)-a(1))/(n);
x=linspace(a(1),a(2),n+1);
yy=zeros(length(x),1);
xx=yy;
xx=a(1);
yy(1)=y;
f=strrep(f,'y','yy');
alfa=0.5
beta=0.5
ipsilon1=0
ipsilon2=1
 
for i=1:n
k1=(-yy(i));
k2=-(yy(i)+beta*h*k1)
yy(i+1)=yy(i)+h*(ipsilon1*k1+ipsilon2*k2);
 
end
 
y=yy
x=x
-------------------------------------------------------------------------
l
 
function vektor1=l(n)
% NAredi vektor [1,2,4,..,4,2,1], da ga lahko za trapezno formulo uporabis
% n je stevilo delilnih tock
 
delna=zeros(length(n),1);
delna(1)=1;
delna(n)=1;
 
for i=2:2:n-1
      delna(i)=4;
end;
 
for i=3:2:n-2
      delna(i)=2;
end;
 
 
vektor1=delna
vektor1=vektor1'
 
--------------------------------------------------------------
>>cd vaje/nummet/DragasKlemen
>>f='sqrt((4-4*cos(t))^2+(6*sin(t))^2)'
 
f =
 
sqrt((4-4*cos(t))^2+(6*sin(t))^2)
 
>>pi
 
ans =
 
    3.1416
 
>>format long
>>t=linspace(0,2*pi,25)
 
t =
 
  Columns 1 through 4
 
                  0   0.26179938779915   0.52359877559830   0.78539816339745
 
  Columns 5 through 8
 
   1.04719755119660   1.30899693899575   1.57079632679490   1.83259571459405
 
  Columns 9 through 12
 
   2.09439510239320   2.35619449019234   2.61799387799149   2.87979326579064
 
  Columns 13 through 16
 
   3.14159265358979   3.40339204138894   3.66519142918809   3.92699081698724
 
  Columns 17 through 20
 
   4.18879020478639   4.45058959258554   4.71238898038469   4.97418836818384
 
  Columns 21 through 24
 
   5.23598775598299   5.49778714378214   5.75958653158129   6.02138591938044
 
  Column 25
 
   6.28318530717959
 
>>y=eval(vectorize(f))
 
y =
 
  Columns 1 through 4
 
                  0   1.55888406268889   3.04748865115163   4.40142965433170
 
  Columns 5 through 8
 
   5.56776436283002   6.50984213284498   7.21110255092798   7.67739952595441
 
  Columns 9 through 12
 
   7.93725393319377   8.03911792412386   8.04442744520093   8.01557062244516
 
  Columns 13 through 16
 
   8.00000000000000   8.01557062244516   8.04442744520093   8.03911792412386
 
  Columns 17 through 20
 
   7.93725393319377   7.67739952595441   7.21110255092798   6.50984213284498
 
  Columns 21 through 24
 
   5.56776436283002   4.40142965433170   3.04748865115163   1.55888406268890
 
  Column 25
 
   0.00000000000000
 
>>t=l(25)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 25
 
     4     2     4     2     4     2     4     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
t =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
>>y*l
??? Input argument 'n' is undefined.
 
Error in ==> /home/vaje/nummet/DragasKlemen/l.m
On line 5  ==> delna=zeros(length(n),1);
 
>>y*t
 
ans =
 
     4.328500991523294e+02
 
>>(y*t*2*pi)/(3*24)
 
ans =
 
  37.77329698896033
 
-----------------------------------------------------------
 
                              < M A T L A B >
                  Copyright 1984-2002 The MathWorks, Inc.
                      Version 6.5.0.180913a Release 13
                                Jun 18 2002
 
 
  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.
 
>>cd vaje/nummet/DragasKlemen
>>formatlong
??? Undefined function or variable 'formatlong'.
 
>>format long
>>f='sin(5*x)*log(x)'
 
f =
 
sin(5*x)*log(x)
 
>>x=linspace(0,1,23)
 
x =
 
  Columns 1 through 4
 
                  0   0.04545454545455   0.09090909090909   0.13636363636364
 
  Columns 5 through 8
 
   0.18181818181818   0.22727272727273   0.27272727272727   0.31818181818182
 
  Columns 9 through 12
 
   0.36363636363636   0.40909090909091   0.45454545454545   0.50000000000000
 
  Columns 13 through 16
 
   0.54545454545455   0.59090909090909   0.63636363636364   0.68181818181818
 
  Columns 17 through 20
 
   0.72727272727273   0.77272727272727   0.81818181818182   0.86363636363636
 
  Columns 21 through 23
 
   0.90909090909091   0.95454545454545   1.00000000000000
 
>>y=eval(vectorize(f))
Warning: Log of zero.
 
y =
 
  Columns 1 through 4
 
                NaN  -0.69647747265166  -1.05280543425921  -1.25564095122646
 
  Columns 5 through 8
 
  -1.34495327266391  -1.34397676388834  -1.27150301909149  -1.14490069577268
 
  Columns 9 through 12
 
  -0.98080368211613  -0.79500539762098  -0.60206352729106  -0.41482927932932
 
  Columns 13 through 16
 
  -0.24401056944824  -0.09783143710504   0.01817643756699   0.10123231907550
 
  Columns 17 through 20
 
   0.15121142043877   0.17040435478939   0.16314882686684   0.13535918779315
 
  Columns 21 through 23
 
   0.09398525150155   0.04643535839198                  0
 
>>plot(x,y)
>>help lim
 
lim.m not found.
 
>>help limit
 
--- help for sym/limit.m ---
 
LIMIT    Limit of an expression.
    LIMIT(F,x,a) takes the limit of the symbolic expression F as x -> a.
    LIMIT(F,a) uses findsym(F) as the independent variable.
    LIMIT(F) uses a = 0 as the limit point.
    LIMIT(F,x,a,'right') or LIMIT(F,x,a,'left') specify the direction
    of a one-sided limit.
 
    Examples:
      syms x a t h;
 
      limit(sin(x)/x)                 returns   1
      limit((x-2)/(x^2-4),2)          returns   1/4
      limit((1+2*t/x)^(3*x),x,inf)    returns   exp(6*t)
      limit(1/x,x,0,'right')          returns   inf
      limit(1/x,x,0,'left')           returns   -inf
      limit((sin(x+h)-sin(x))/h,h,0)  returns   cos(x)
      v = [(1 + a/x)^x, exp(-x)];
      limit(v,x,inf,'left')           returns   [exp(a),  0]
 
>>limit(sin(5*x)*log(x),x,0)
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>limit(sin(5*x)*log(x),x,0)
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>limit(sin(5*x)*log(x),0)
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>limit(sin(5*x)*log(x))
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>limit(sin(5*x)*log(x),x,0)
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>help limit
 
--- help for sym/limit.m ---
 
LIMIT    Limit of an expression.
    LIMIT(F,x,a) takes the limit of the symbolic expression F as x -> a.
    LIMIT(F,a) uses findsym(F) as the independent variable.
    LIMIT(F) uses a = 0 as the limit point.
    LIMIT(F,x,a,'right') or LIMIT(F,x,a,'left') specify the direction
    of a one-sided limit.
 
    Examples:
      syms x a t h;
 
      limit(sin(x)/x)                 returns   1
      limit((x-2)/(x^2-4),2)          returns   1/4
      limit((1+2*t/x)^(3*x),x,inf)    returns   exp(6*t)
      limit(1/x,x,0,'right')          returns   inf
      limit(1/x,x,0,'left')           returns   -inf
      limit((sin(x+h)-sin(x))/h,h,0)  returns   cos(x)
      v = [(1 + a/x)^x, exp(-x)];
      limit(v,x,inf,'left')           returns   [exp(a),  0]
 
>>limit('sin(5*x)*log(x)',x,0)
??? No appropriate methods for function limit.
 
>>limit(f,x,0)
??? No appropriate methods for function limit.
 
>>limit(vectorize(f),x,0)
??? No appropriate methods for function limit.
 
>>limit(eval(vectorize(f)),x,0)
Warning: Log of zero.
??? No appropriate methods for function limit.
 
>>help limit
 
--- help for sym/limit.m ---
 
LIMIT    Limit of an expression.
    LIMIT(F,x,a) takes the limit of the symbolic expression F as x -> a.
    LIMIT(F,a) uses findsym(F) as the independent variable.
    LIMIT(F) uses a = 0 as the limit point.
    LIMIT(F,x,a,'right') or LIMIT(F,x,a,'left') specify the direction
    of a one-sided limit.
 
    Examples:
      syms x a t h;
 
      limit(sin(x)/x)                 returns   1
      limit((x-2)/(x^2-4),2)          returns   1/4
      limit((1+2*t/x)^(3*x),x,inf)    returns   exp(6*t)
      limit(1/x,x,0,'right')          returns   inf
      limit(1/x,x,0,'left')           returns   -inf
      limit((sin(x+h)-sin(x))/h,h,0)  returns   cos(x)
      v = [(1 + a/x)^x, exp(-x)];
      limit(v,x,inf,'left')           returns   [exp(a),  0]
 
>>limit(f)
??? No appropriate methods for function limit.
 
>>limit(sin(5*x)*log(x))
Warning: Log of zero.
??? Error using ==> *
Inner matrix dimensions must agree.
 
>>limit(sin(5*x).*log(x))
Warning: Log of zero.
??? No appropriate methods for function limit.
 
>>limit(sin(5*x).*log(x),x,0)
Warning: Log of zero.
??? No appropriate methods for function limit.
 
>>  limit(1/x,x,0,'right')
??? Error using ==> /
Matrix dimensions must agree.
 
>>limit(sin(5*t)*log(t),t,0)
??? Undefined function or variable 't'.
 
>>limit(sin(5*x)*log(t),t,0)
??? Undefined function or variable 't'.
 
>>y
 
y =
 
  Columns 1 through 4
 
                NaN  -0.69647747265166  -1.05280543425921  -1.25564095122646
 
  Columns 5 through 8
 
  -1.34495327266391  -1.34397676388834  -1.27150301909149  -1.14490069577268
 
  Columns 9 through 12
 
  -0.98080368211613  -0.79500539762098  -0.60206352729106  -0.41482927932932
 
  Columns 13 through 16
 
  -0.24401056944824  -0.09783143710504   0.01817643756699   0.10123231907550
 
  Columns 17 through 20
 
   0.15121142043877   0.17040435478939   0.16314882686684   0.13535918779315
 
  Columns 21 through 23
 
   0.09398525150155   0.04643535839198                  0
 
>>y(0)
??? Subscript indices must either be real positive integers or logicals.
 
>>y(1)
 
ans =
 
   NaN
 
>>y(1)=0
 
y =
 
  Columns 1 through 4
 
                  0  -0.69647747265166  -1.05280543425921  -1.25564095122646
 
  Columns 5 through 8
 
  -1.34495327266391  -1.34397676388834  -1.27150301909149  -1.14490069577268
 
  Columns 9 through 12
 
  -0.98080368211613  -0.79500539762098  -0.60206352729106  -0.41482927932932
 
  Columns 13 through 16
 
  -0.24401056944824  -0.09783143710504   0.01817643756699   0.10123231907550
 
  Columns 17 through 20
 
   0.15121142043877   0.17040435478939   0.16314882686684   0.13535918779315
 
  Columns 21 through 23
 
   0.09398525150155   0.04643535839198                  0
 
>>plot(x,y)
>>help zeros
 
ZEROS  Zeros array.
    ZEROS(N) is an N-by-N matrix of zeros.
    ZEROS(M,N) or ZEROS([M,N]) is an M-by-N matrix of zeros.
    ZEROS(M,N,P,...) or ZEROS([M N P ...]) is an M-by-N-by-P-by-...
    array of zeros.
    ZEROS(SIZE(A)) is the same size as A and all zeros.
 
    See also EYE, ONES.
 
>>zeros(1,5)
 
ans =
 
     0     0     0     0     0
 
>>help l.m
 
  NAredi vektor [1,2,4,..,4,2,1], da ga lahko za trapezno formulo uporabis
 
>>l(n)
??? Undefined function or variable 'n'.
 
>>l(23)
??? Error: File: /home/vaje/nummet/DragasKlemen/l.m Line: 15 Column: 1
"end" expected, "End of Input" found.
 
>>l(23)
>>vektor
??? Undefined function or variable 'vektor'.
 
>>l(23)
 
vektor =
 
  Columns 1 through 13
 
     1     2     2     2     2     2     2     2     2     2     2     2     2
 
  Columns 14 through 23
 
     2     2     2     2     2     2     2     2     0     1
 
 
ans =
 
  Columns 1 through 13
 
     1     2     2     2     2     2     2     2     2     2     2     2     2
 
  Columns 14 through 23
 
     2     2     2     2     2     2     2     2     0     1
 
>>vektor=zeros(23,1)
 
vektor =
 
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
 
>>vektor=vektor+2
 
vektor =
 
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
 
>>vektor(1)=1
 
vektor =
 
     1
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
 
>>vektor(n)=1
??? Undefined function or variable 'n'.
 
>>vektor(23)=1
 
vektor =
 
     1
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     1
 
>>y
 
y =
 
  Columns 1 through 4
 
                  0  -0.69647747265166  -1.05280543425921  -1.25564095122646
 
  Columns 5 through 8
 
  -1.34495327266391  -1.34397676388834  -1.27150301909149  -1.14490069577268
 
  Columns 9 through 12
 
  -0.98080368211613  -0.79500539762098  -0.60206352729106  -0.41482927932932
 
  Columns 13 through 16
 
  -0.24401056944824  -0.09783143710504   0.01817643756699   0.10123231907550
 
  Columns 17 through 20
 
   0.15121142043877   0.17040435478939   0.16314882686684   0.13535918779315
 
  Columns 21 through 23
 
   0.09398525150155   0.04643535839198                  0
 
>>y*vektor
 
ans =
 
-20.72969669208068
 
>>grid
>>rezultat1=y*vektor
 
rezultat1 =
 
-20.72969669208068
 
>>l(23)
Warning: File: /home/vaje/nummet/DragasKlemen/l.m Line: 16 Column: 1
Unmatched "end".
(Type "warning off MATLAB:m_warning_end_without_block" to suppress this warning.
)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
 
ans =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
>>l(23)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
 
ans =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
>>l(23)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
 
ans =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
>>l(23)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
ans =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
>>y*vektor1
??? Undefined function or variable 'vektor1'.
 
>>vektor1
??? Undefined function or variable 'vektor1'.
 
>>vektor1=l(23)
 
vektor1 =
 
  Columns 1 through 13
 
     1     4     2     4     2     4     2     4     2     4     2     4     2
 
  Columns 14 through 23
 
     4     2     4     2     4     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
>>y*vektor1
 
ans =
 
-31.32015824716958
 
>>rezultat1
 
rezultat1 =
 
-20.72969669208068
 
>>rezultat1/44
 
ans =
 
  -0.47112947027456
 
>>y*vektor1/66
 
ans =
 
  -0.47454785222984
 
>>f='(1-(cos(x))^2)/sin(x^2)'
 
f =
 
(1-(cos(x))^2)/sin(x^2)
 
>>x=linspace(0,1,21)
 
x =
 
  Columns 1 through 4
 
                  0   0.05000000000000   0.10000000000000   0.15000000000000
 
  Columns 5 through 8
 
   0.20000000000000   0.25000000000000   0.30000000000000   0.35000000000000
 
  Columns 9 through 12
 
   0.40000000000000   0.45000000000000   0.50000000000000   0.55000000000000
 
  Columns 13 through 16
 
   0.60000000000000   0.65000000000000   0.70000000000000   0.75000000000000
 
  Columns 17 through 20
 
   0.80000000000000   0.85000000000000   0.90000000000000   0.95000000000000
 
  Column 21
 
   1.00000000000000
 
>>y=eval(vectorize(x))
??? Error: Expected a variable, function, or constant, found "end of line".
 
>>f='(1-(cos(x))^2)/sin(x^2)'
 
f =
 
(1-(cos(x))^2)/sin(x^2)
 
>>y=eval(vectorize(x))
??? Error: Expected a variable, function, or constant, found "end of line".
 
>>x=linspace(0,1,21)
 
x =
 
  Columns 1 through 4
 
                  0   0.05000000000000   0.10000000000000   0.15000000000000
 
  Columns 5 through 8
 
   0.20000000000000   0.25000000000000   0.30000000000000   0.35000000000000
 
  Columns 9 through 12
 
   0.40000000000000   0.45000000000000   0.50000000000000   0.55000000000000
 
  Columns 13 through 16
 
   0.60000000000000   0.65000000000000   0.70000000000000   0.75000000000000
 
  Columns 17 through 20
 
   0.80000000000000   0.85000000000000   0.90000000000000   0.95000000000000
 
  Column 21
 
   1.00000000000000
 
>>y=eval(vectorize(x))
??? Error: Expected a variable, function, or constant, found "end of line".
 
>>y=eval(vectorize(f))
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
 
y =
 
  Columns 1 through 4
 
                NaN   0.99916798519447   0.99668771931686   0.99260621290472
 
  Columns 5 through 8
 
   0.98700075410982   0.97997738638897   0.97166891682641   0.96223258574719
 
  Columns 9 through 12
 
   0.95184755433255   0.94071238689149   0.92904271927786   0.91706931681816
 
  Columns 13 through 16
 
   0.90503673742353   0.89320283311495   0.88183935261748   0.87123395816760
 
  Columns 17 through 20
 
   0.86169405442325   0.85355296616416   0.84717922539516   0.84299008833582
 
  Column 21
 
   0.84147098480790
 
>>plot(x,y)
>>grid
>>y
 
y =
 
  Columns 1 through 4
 
                NaN   0.99916798519447   0.99668771931686   0.99260621290472
 
  Columns 5 through 8
 
   0.98700075410982   0.97997738638897   0.97166891682641   0.96223258574719
 
  Columns 9 through 12
 
   0.95184755433255   0.94071238689149   0.92904271927786   0.91706931681816
 
  Columns 13 through 16
 
   0.90503673742353   0.89320283311495   0.88183935261748   0.87123395816760
 
  Columns 17 through 20
 
   0.86169405442325   0.85355296616416   0.84717922539516   0.84299008833582
 
  Column 21
 
   0.84147098480790
 
>>y(1)=1
 
y =
 
  Columns 1 through 5
 
   1.00000000000000   0.99916798519447   0.99668771931686   0.99260621290472   0.98700075410982
 
  Columns 6 through 10
 
   0.97997738638897   0.97166891682641   0.96223258574719   0.95184755433255   0.94071238689149
 
  Columns 11 through 15
 
   0.92904271927786   0.91706931681816   0.90503673742353   0.89320283311495   0.88183935261748
 
  Columns 16 through 20
 
   0.87123395816760   0.86169405442325   0.85355296616416   0.84717922539516   0.84299008833582
 
  Column 21
 
   0.84147098480790
 
>>vektor
 
vektor =
 
     1
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     1
 
>>vektormoj=zeros(21,1)+2
 
vektormoj =
 
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
 
>>vektormoj(1)=1
 
vektormoj =
 
     1
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
 
>>vektormoj(21)=1
 
vektormoj =
 
     1
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     2
     1
 
>>y*vektormoj
 
ans =
 
  37.01095649170878
 
>>trapezna=y*vektormoj/40
 
trapezna =
 
   0.92527391229272
 
>>help l
 
  NAredi vektor [1,2,4,..,4,2,1], da ga lahko za trapezno formulo uporabis
 
>>l(21)
 
vektor1 =
 
  Columns 1 through 16
 
     1     4     2     4     2     4     2     4     2     4     2     4     2     4     2     4
 
  Columns 17 through 21
 
     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
ans =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
>>Simpson=y*l(21)/60
 
vektor1 =
 
  Columns 1 through 16
 
     1     4     2     4     2     4     2     4     2     4     2     4     2     4     2     4
 
  Columns 17 through 21
 
     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
Simpson =
 
   0.92527413218606
 
-----------------------------------------------------------------------------
< M A T L A B >
                  Copyright 1984-2002 The MathWorks, Inc.
                      Version 6.5.0.180913a Release 13
                                Jun 18 2002
 
 
  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.
 
>>cd vaje/nummet/DragasKlemen
>>dir
 
.                   frisi_tangento.m    newton.m
..                  frisi_tangento.m~   novenaloge3.pdf
64000146-sedma.pdf  funkcija.m          polarni.m
64020123-29.pdf     funkcija.m~         polarni.m~
64020123-32.pdf     gauss.m             risi_tangento.m
64020123-35.pdf     gauss.m~            risi_tangento.m~
6dn1vaja.m          gausszajdl.m        robniproblem.m
6dn2vaja.m          gausszajdl.m~       sekantna.m
6log                jac.m               sor.m
Attachement         jacobian.m          sor1.m
DN1.pdf             l.m                 sor1.m~
DN2.pdf             l.m~                sork.m
DN3.pdf             lcg.m               sork.m~
DN4.pdf             matlab              sorla.m
DN5.pdf             mrand.m             trijacobi.m
DN6.pdf             naloga71.m          trijacobi.m~
VAJA6_3.m           naloga71a.m         trijacobi1.m
VAJA6_3podatki.m    naloga72.m          trijacobi1.m~
VAJA6_3podatki.m~   naloga73.m          vaja8log.m
bisekcija.m         naloga74.m          zapisnik.m
diary               naloga75.m          zgodovina.m
direktna.m          naloge_nove.pdf     zgodovina.txt
direktna.m~         naloge_nove1.pdf
dn5.txt             naloge_nove2.pdf
 
>>help limit
 
--- help for sym/limit.m ---
 
LIMIT    Limit of an expression.
    LIMIT(F,x,a) takes the limit of the symbolic expression F as x -> a.
    LIMIT(F,a) uses findsym(F) as the independent variable.
    LIMIT(F) uses a = 0 as the limit point.
    LIMIT(F,x,a,'right') or LIMIT(F,x,a,'left') specify the direction
    of a one-sided limit.
 
    Examples:
      syms x a t h;
 
      limit(sin(x)/x)                 returns   1
      limit((x-2)/(x^2-4),2)          returns   1/4
      limit((1+2*t/x)^(3*x),x,inf)    returns   exp(6*t)
      limit(1/x,x,0,'right')          returns   inf
      limit(1/x,x,0,'left')           returns   -inf
      limit((sin(x+h)-sin(x))/h,h,0)  returns   cos(x)
      v = [(1 + a/x)^x, exp(-x)];
      limit(v,x,inf,'left')           returns   [exp(a),  0]
 
>>limit(1/(x^2)-sin(x)/x^3)
??? Undefined function or variable 'x'.
 
>>x=0
 
x =
 
     0
 
>>limit(1/(x^2)-sin(x)/x^3)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
??? No appropriate methods for function limit.
 
>>limit(1/(x^2)-sin(x)/x^3,0)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
??? No appropriate methods for function limit.
 
>>f='1/(x^2)-sin(x)/x^3'
 
f =
 
1/(x^2)-sin(x)/x^3
 
>>x=linspace(0,2,23);
>>y=eval(vectorize(f));
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
>>y(1)
 
ans =
 
   NaN
 
>>y(2)
 
ans =
 
    0.1666
 
>>format long
>>x=linspace(0,2,23);
>>y=eval(vectorize(f));
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
>>y
 
y =
 
  Columns 1 through 4
 
                NaN   0.16659780969356   0.16639140130314   0.16604792852290
 
  Columns 5 through 8
 
   0.16556820120287   0.16495334923049   0.16420481864753   0.16332436668579
 
  Columns 9 through 12
 
   0.16231405574210   0.16117624631810   0.15991358895429   0.15852901519210
 
  Columns 13 through 16
 
   0.15702572760166   0.15540718891694   0.15367711032348   0.15183943894713
 
  Columns 17 through 20
 
   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>y(1)=1/6
 
y =
 
  Columns 1 through 4
 
   0.16666666666667   0.16659780969356   0.16639140130314   0.16604792852290
 
  Columns 5 through 8
 
   0.16556820120287   0.16495334923049   0.16420481864753   0.16332436668579
 
  Columns 9 through 12
 
   0.16231405574210   0.16117624631810   0.15991358895429   0.15852901519210
 
  Columns 13 through 16
 
   0.15702572760166   0.15540718891694   0.15367711032348   0.15183943894713
 
  Columns 17 through 20
 
   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>plot(x,y)
>>1/11
 
ans =
 
   0.09090909090909
 
>>*2
??? *2
    |
Error: "End of Input" expected, "*" found.
 
>>2/11
 
ans =
 
   0.18181818181818
 
>>x
 
x =
 
  Columns 1 through 4
 
                  0   0.09090909090909   0.18181818181818   0.27272727272727
 
  Columns 5 through 8
 
   0.36363636363636   0.45454545454545   0.54545454545455   0.63636363636364
 
  Columns 9 through 12
 
   0.72727272727273   0.81818181818182   0.90909090909091   1.00000000000000
 
  Columns 13 through 16
 
   1.09090909090909   1.18181818181818   1.27272727272727   1.36363636363636
 
  Columns 17 through 20
 
   1.45454545454545   1.54545454545455   1.63636363636364   1.72727272727273
 
  Columns 21 through 23
 
   1.81818181818182   1.90909090909091   2.00000000000000
 
>>help limit
 
--- help for sym/limit.m ---
 
LIMIT    Limit of an expression.
    LIMIT(F,x,a) takes the limit of the symbolic expression F as x -> a.
    LIMIT(F,a) uses findsym(F) as the independent variable.
    LIMIT(F) uses a = 0 as the limit point.
    LIMIT(F,x,a,'right') or LIMIT(F,x,a,'left') specify the direction
    of a one-sided limit.
 
    Examples:
      syms x a t h;
 
      limit(sin(x)/x)                 returns   1
      limit((x-2)/(x^2-4),2)          returns   1/4
      limit((1+2*t/x)^(3*x),x,inf)    returns   exp(6*t)
      limit(1/x,x,0,'right')          returns   inf
      limit(1/x,x,0,'left')           returns   -inf
      limit((sin(x+h)-sin(x))/h,h,0)  returns   cos(x)
      v = [(1 + a/x)^x, exp(-x)];
      limit(v,x,inf,'left')           returns   [exp(a),  0]
 
>>h=1/11
 
h =
 
   0.09090909090909
 
>>G=[1,3,5;15,31,12]
 
G =
 
     1     3     5
    15    31    12
 
>>G=[1,1,1;0,h,2*h;0,h^2,4*h^2]
 
G =
 
   1.00000000000000   1.00000000000000   1.00000000000000
                  0   0.09090909090909   0.18181818181818
                  0   0.00826446280992   0.03305785123967
 
>>K=zeros(3,1)
 
K =
 
     0
     0
     0
 
>>K(1)=2*sqrt(2*h)
 
K =
 
   0.85280286542244
                  0
                  0
 
>>K(2)=(2*(2*h)^(3/2))/3
 
K =
 
   0.85280286542244
   0.05168502214681
                  0
 
>>K(2)=(2*(2*h)^(5/2))/5
 
K =
 
   0.85280286542244
   0.00563836605238
                  0
 
>>K(2)=(2*(2*h)^(3/2))/3
 
K =
 
   0.85280286542244
   0.05168502214681
                  0
 
>>K(3)=(2*(2*h)^(5/2))/5
 
K =
 
   0.85280286542244
   0.05168502214681
   0.00563836605238
 
>>Asingularnidel=G\K
 
Asingularnidel =
 
   0.34112114616898
   0.45482819489197
   0.05685352436150
 
>>y
 
y =
 
  Columns 1 through 4
 
   0.16666666666667   0.16659780969356   0.16639140130314   0.16604792852290
 
  Columns 5 through 8
 
   0.16556820120287   0.16495334923049   0.16420481864753   0.16332436668579
 
  Columns 9 through 12
 
   0.16231405574210   0.16117624631810   0.15991358895429   0.15852901519210
 
  Columns 13 through 16
 
   0.15702572760166   0.15540718891694   0.15367711032348   0.15183943894713
 
  Columns 17 through 20
 
   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>f
 
f =
 
1/(x^2)-sin(x)/x^3
   delniintegral=A(1)/6+A(2)*(1/(h^2)-sin(h)/h^3)+A(3)*(1/((2*h)^2)-sin(2*h)/(2*h)^3)
??? Undefined function or variable 'A'.
 
>>A=Asingularnidel
 
A =
 
   0.34112114616898
   0.45482819489197
   0.05685352436150
 
>>delniintegral=A(1)/6+A(2)*(1/(h^2)-sin(h)/h^3)+A(3)*(1/((2*h)^2)-sin(2*h)/(2*h)^3)
 
delniintegral =
 
   0.14208684300490
 
>>help l.m
 
  NAredi vektor [1,2,4,..,4,2,1], da ga lahko za trapezno formulo uporabis
  n je stevilo delilnih tock
 
>>l(21)
 
vektor1 =
 
  Columns 1 through 16
 
     1     4     2     4     2     4     2     4     2     4     2     4     2     4     2     4
 
  Columns 17 through 21
 
     2     4     2     4     1
 
 
vektor1 =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
 
ans =
 
     1
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     2
     4
     1
 
>>y
 
y =
 
  Columns 1 through 5
 
   0.16666666666667   0.16659780969356   0.16639140130314   0.16604792852290   0.16556820120287
 
  Columns 6 through 10
 
   0.16495334923049   0.16420481864753   0.16332436668579   0.16231405574210   0.16117624631810
 
  Columns 11 through 15
 
   0.15991358895429   0.15852901519210   0.15702572760166   0.15540718891694   0.15367711032348
 
  Columns 16 through 20
 
   0.15183943894713   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>length(y)
 
ans =
 
    23
 
>>p=y[3:end,1]
??? p=y[3:end,1]
       |
Error: Missing operator, comma, or semicolon.
 
>>p=y[3:end]
??? p=y[3:end]
       |
Error: Missing operator, comma, or semicolon.
 
>>p=y[1,3:end]
??? p=y[1,3:end]
       |
Error: Missing operator, comma, or semicolon.
 
>>p=y[3:end]
??? p=y[3:end]
       |
Error: Missing operator, comma, or semicolon.
 
>>p=y[3;end]
??? p=y[3;end]
       |
Error: Missing operator, comma, or semicolon.
 
>>help ;
 
HELP topics:
 
matlab/general       -  General purpose commands.
matlab/ops           -  Operators and special characters.
matlab/lang          -  Programming language constructs.
matlab/elmat         -  Elementary matrices and matrix manipulation.
matlab/elfun         -  Elementary math functions.
matlab/specfun       -  Specialized math functions.
matlab/matfun        -  Matrix functions - numerical linear algebra.
matlab/datafun       -  Data analysis and Fourier transforms.
matlab/audio         -  Audio support.
matlab/polyfun       -  Interpolation and polynomials.
matlab/funfun        -  Function functions and ODE solvers.
matlab/sparfun       -  Sparse matrices.
matlab/graph2d       -  Two dimensional graphs.
matlab/graph3d       -  Three dimensional graphs.
matlab/specgraph     -  Specialized graphs.
matlab/graphics      -  Handle Graphics.
matlab/uitools       -  Graphical user interface tools.
matlab/strfun        -  Character strings.
matlab/iofun         -  File input/output.
matlab/timefun       -  Time and dates.
matlab/datatypes     -  Data types and structures.
matlab/verctrl       -  Version control.
matlab/demos         -  Examples and demonstrations.
toolbox/local        -  Preferences.
simulink/simulink    -  Simulink
simulink/blocks      -  Simulink block library.
simulink/components  -  Simulink components.
simulink/fixedandfloat -  (No table of contents file)
fixedandfloat/fxpdemos -  Fixed-Point Blockset Demos
fixedandfloat/obsolete -  Obsolete Fixed-Point Blockset
simulink/simdemos    -  Simulink 4 demonstrations and samples.
simdemos/aerospace   -  Simulink: Aerospace model demonstrations and samples.
simdemos/automotive  -  Simulink: Automotive model demonstrations and samples.
simdemos/simfeatures -  Simulink: Feature demonstrations and samples.
simdemos/simgeneral  -  Simulink: General model demonstrations and samples.
simdemos/simnew      -  Simulink: New features model demonstrations and samples.
simulink/dee         -  Differential Equation Editor
simulink/dastudio    -  (No table of contents file)
stateflow/stateflow  -  (No table of contents file)
stateflow/sfdemos    -  Stateflow demonstrations and samples.
stateflow/coder      -  (No table of contents file)
control/control      -  Control System Toolbox.
control/ctrlguis     -  Control System Toolbox -- GUI support functions.
control/ctrlobsolete -  Control System Toolbox -- obsolete commands.
control/ctrlutil     -  (No table of contents file)
control/ctrldemos    -  Control System Toolbox -- Demos.
toolbox/optim        -  Optimization Toolbox
toolbox/sb2sl        -  SB2SL (converts SystemBuild to Simulink)
signal/signal        -  Signal Processing Toolbox
signal/sigtools      -  Filter Design & Analysis Tool (GUI)
signal/sptoolgui     -  Signal Processing Toolbox GUI
signal/sigdemos      -  Signal Processing Toolbox Demonstrations.
toolbox/symbolic     -  Symbolic Math Toolbox.
 
For more help on directory/topic, type "help topic".
For command syntax information, type "help syntax".
 
 
>>y
 
y =
 
  Columns 1 through 5
 
   0.16666666666667   0.16659780969356   0.16639140130314   0.16604792852290   0.16556820120287
 
  Columns 6 through 10
 
   0.16495334923049   0.16420481864753   0.16332436668579   0.16231405574210   0.16117624631810
 
  Columns 11 through 15
 
   0.15991358895429   0.15852901519210   0.15702572760166   0.15540718891694   0.15367711032348
 
  Columns 16 through 20
 
   0.15183943894713   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>y[1,3:end]
??? y[1,3:end]
     |
Error: Missing operator, comma, or semicolon.
 
>>y[1,3:end]
??? y[1,3:end]
     |
Error: Missing operator, comma, or semicolon.
 
>>y
 
y =
 
  Columns 1 through 5
 
   0.16666666666667   0.16659780969356   0.16639140130314   0.16604792852290   0.16556820120287
 
  Columns 6 through 10
 
   0.16495334923049   0.16420481864753   0.16332436668579   0.16231405574210   0.16117624631810
 
  Columns 11 through 15
 
   0.15991358895429   0.15852901519210   0.15702572760166   0.15540718891694   0.15367711032348
 
  Columns 16 through 20
 
   0.15183943894713   0.14989834459592   0.14785820580949   0.14572359527379   0.14349926466072
 
  Columns 21 through 23
 
   0.14119012895479   0.13880125033065   0.13633782164679
 
>>y[3:end]
??? y[3:end]
     |
Error: Missing operator, comma, or semicolon.
 
>>y[3:end,1]
??? y[3:end,1]
     |
Error: Missing operator, comma, or semicolon.
 
>>y(3:end,1)
 
ans =
 
   Empty matrix: 0-by-1
 
>>y(1,3:end)
 
ans =
 
  Columns 1 through 5
 
   0.16639140130314   0.16604792852290   0.16556820120287   0.16495334923049   0.16420481864753
 
  Columns 6 through 10
 
   0.16332436668579   0.16231405574210   0.16117624631810   0.15991358895429   0.15852901519210
 
  Columns 11 through 15
 
   0.15702572760166   0.15540718891694   0.15367711032348   0.15183943894713   0.14989834459592
 
  Columns 16 through 20
 
   0.14785820580
------------------------------------------------------------------------------
 
 
 

 

Hosted by www.Geocities.ws

1