2. laborgyakorlat, házik megoldásai

Contents

clear all, close all

2. feladat

x=1:50; y=1:20;
[uj_x,uj_y]=meshgrid(x,y);
A=sin(pi*uj_x/4)+uj_y.^3/1000
A =
  Columns 1 through 7
    0.7081    1.0010    0.7081    0.0010   -0.7061   -0.9990   -0.7061
    0.7151    1.0080    0.7151    0.0080   -0.6991   -0.9920   -0.6991
    0.7341    1.0270    0.7341    0.0270   -0.6801   -0.9730   -0.6801
    0.7711    1.0640    0.7711    0.0640   -0.6431   -0.9360   -0.6431
    0.8321    1.1250    0.8321    0.1250   -0.5821   -0.8750   -0.5821
    0.9231    1.2160    0.9231    0.2160   -0.4911   -0.7840   -0.4911
    1.0501    1.3430    1.0501    0.3430   -0.3641   -0.6570   -0.3641
    1.2191    1.5120    1.2191    0.5120   -0.1951   -0.4880   -0.1951
    1.4361    1.7290    1.4361    0.7290    0.0219   -0.2710    0.0219
    1.7071    2.0000    1.7071    1.0000    0.2929         0    0.2929
    2.0381    2.3310    2.0381    1.3310    0.6239    0.3310    0.6239
    2.4351    2.7280    2.4351    1.7280    1.0209    0.7280    1.0209
    2.9041    3.1970    2.9041    2.1970    1.4899    1.1970    1.4899
    3.4511    3.7440    3.4511    2.7440    2.0369    1.7440    2.0369
    4.0821    4.3750    4.0821    3.3750    2.6679    2.3750    2.6679
    4.8031    5.0960    4.8031    4.0960    3.3889    3.0960    3.3889
    5.6201    5.9130    5.6201    4.9130    4.2059    3.9130    4.2059
    6.5391    6.8320    6.5391    5.8320    5.1249    4.8320    5.1249
    7.5661    7.8590    7.5661    6.8590    6.1519    5.8590    6.1519
    8.7071    9.0000    8.7071    8.0000    7.2929    7.0000    7.2929
  Columns 8 through 14
    0.0010    0.7081    1.0010    0.7081    0.0010   -0.7061   -0.9990
    0.0080    0.7151    1.0080    0.7151    0.0080   -0.6991   -0.9920
    0.0270    0.7341    1.0270    0.7341    0.0270   -0.6801   -0.9730
    0.0640    0.7711    1.0640    0.7711    0.0640   -0.6431   -0.9360
    0.1250    0.8321    1.1250    0.8321    0.1250   -0.5821   -0.8750
    0.2160    0.9231    1.2160    0.9231    0.2160   -0.4911   -0.7840
    0.3430    1.0501    1.3430    1.0501    0.3430   -0.3641   -0.6570
    0.5120    1.2191    1.5120    1.2191    0.5120   -0.1951   -0.4880
    0.7290    1.4361    1.7290    1.4361    0.7290    0.0219   -0.2710
    1.0000    1.7071    2.0000    1.7071    1.0000    0.2929         0
    1.3310    2.0381    2.3310    2.0381    1.3310    0.6239    0.3310
    1.7280    2.4351    2.7280    2.4351    1.7280    1.0209    0.7280
    2.1970    2.9041    3.1970    2.9041    2.1970    1.4899    1.1970
    2.7440    3.4511    3.7440    3.4511    2.7440    2.0369    1.7440
    3.3750    4.0821    4.3750    4.0821    3.3750    2.6679    2.3750
    4.0960    4.8031    5.0960    4.8031    4.0960    3.3889    3.0960
    4.9130    5.6201    5.9130    5.6201    4.9130    4.2059    3.9130
    5.8320    6.5391    6.8320    6.5391    5.8320    5.1249    4.8320
    6.8590    7.5661    7.8590    7.5661    6.8590    6.1519    5.8590
    8.0000    8.7071    9.0000    8.7071    8.0000    7.2929    7.0000
  Columns 15 through 21
   -0.7061    0.0010    0.7081    1.0010    0.7081    0.0010   -0.7061
   -0.6991    0.0080    0.7151    1.0080    0.7151    0.0080   -0.6991
   -0.6801    0.0270    0.7341    1.0270    0.7341    0.0270   -0.6801
   -0.6431    0.0640    0.7711    1.0640    0.7711    0.0640   -0.6431
   -0.5821    0.1250    0.8321    1.1250    0.8321    0.1250   -0.5821
   -0.4911    0.2160    0.9231    1.2160    0.9231    0.2160   -0.4911
   -0.3641    0.3430    1.0501    1.3430    1.0501    0.3430   -0.3641
   -0.1951    0.5120    1.2191    1.5120    1.2191    0.5120   -0.1951
    0.0219    0.7290    1.4361    1.7290    1.4361    0.7290    0.0219
    0.2929    1.0000    1.7071    2.0000    1.7071    1.0000    0.2929
    0.6239    1.3310    2.0381    2.3310    2.0381    1.3310    0.6239
    1.0209    1.7280    2.4351    2.7280    2.4351    1.7280    1.0209
    1.4899    2.1970    2.9041    3.1970    2.9041    2.1970    1.4899
    2.0369    2.7440    3.4511    3.7440    3.4511    2.7440    2.0369
    2.6679    3.3750    4.0821    4.3750    4.0821    3.3750    2.6679
    3.3889    4.0960    4.8031    5.0960    4.8031    4.0960    3.3889
    4.2059    4.9130    5.6201    5.9130    5.6201    4.9130    4.2059
    5.1249    5.8320    6.5391    6.8320    6.5391    5.8320    5.1249
    6.1519    6.8590    7.5661    7.8590    7.5661    6.8590    6.1519
    7.2929    8.0000    8.7071    9.0000    8.7071    8.0000    7.2929
  Columns 22 through 28
   -0.9990   -0.7061    0.0010    0.7081    1.0010    0.7081    0.0010
   -0.9920   -0.6991    0.0080    0.7151    1.0080    0.7151    0.0080
   -0.9730   -0.6801    0.0270    0.7341    1.0270    0.7341    0.0270
   -0.9360   -0.6431    0.0640    0.7711    1.0640    0.7711    0.0640
   -0.8750   -0.5821    0.1250    0.8321    1.1250    0.8321    0.1250
   -0.7840   -0.4911    0.2160    0.9231    1.2160    0.9231    0.2160
   -0.6570   -0.3641    0.3430    1.0501    1.3430    1.0501    0.3430
   -0.4880   -0.1951    0.5120    1.2191    1.5120    1.2191    0.5120
...

3. feladat

i=13; j=24;
a_explicit=i^3/1000+sin(pi*j/4)
a_matrixbeli=A(i,j)
a_explicit =
    2.1970
a_matrixbeli =
    2.1970

4. feladat

B=A(:,1:20)+eye(20);
det_B=det(B)
se_min=min(eig(B))
minB=min(B);
min_6odik_oszlop=minB(6)
diagmax=max(diag(B))
det_B =
  -34.2105
se_min =
   -0.6952
min_6odik_oszlop =
   -0.9990
diagmax =
     9

5. feladat

load pontszamok

6. feladat

pontszamok(:,5)=(pontszamok(:,2)+pontszamok(:,3)+pontszamok(:,4))/3
pontszamok =
    1.0000   68.0000   45.0000   92.0000   68.3333
    2.0000   83.0000   54.0000   93.0000   76.6667
    3.0000   61.0000   67.0000   91.0000   73.0000
    4.0000   70.0000   66.0000   92.0000   76.0000
    5.0000   75.0000   68.0000   96.0000   79.6667
    6.0000   82.0000   67.0000   90.0000   79.6667
    7.0000   57.0000   65.0000   89.0000   70.3333
    8.0000    5.0000   69.0000   89.0000   54.3333
    9.0000   76.0000   62.0000   97.0000   78.3333
   10.0000   85.0000   52.0000   94.0000   77.0000
   11.0000   62.0000   34.0000   87.0000   61.0000
   12.0000   71.0000   45.0000   85.0000   67.0000
   13.0000   96.0000   56.0000   45.0000   65.6667
   14.0000   78.0000   65.0000   87.0000   76.6667
   15.0000   76.0000   43.0000   97.0000   72.0000
   16.0000   68.0000   76.0000   95.0000   79.6667
   17.0000   72.0000   65.0000   89.0000   75.3333
   18.0000   75.0000   67.0000   88.0000   76.6667
   19.0000   83.0000   68.0000   91.0000   80.6667
   20.0000   93.0000   90.0000   92.0000   91.6667

7. feladat

otodik_eredmenye=pontszamok(5,:)
otodik_eredmenye =
    5.0000   75.0000   68.0000   96.0000   79.6667

8. feladat

[m,p]=max(pontszamok(:,5));
legtobb_pont=m
diak=p
[m,p]=min(pontszamok(:,5));
legkevesebb_pont=m
diak=p
legtobb_pont =
   91.6667
diak =
    20
legkevesebb_pont =
   54.3333
diak =
     8

9. feladat

atlag=mean(pontszamok(:,2:4))
atlag =
   71.8000   61.2000   88.9500