MLTutorBeispielerstellung: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 5: | Zeile 5: | ||
=== regpol.m === |
=== regpol.m === |
||
<pre> |
<pre> |
||
− | + | function [V,F,R,r]=regpol(typ,a) |
|
− | + | switch lower(typ(1)) |
|
case 't' |
case 't' |
||
V=a^3/12*sqrt(2); |
V=a^3/12*sqrt(2); |
||
Zeile 37: | Zeile 37: | ||
=== ml_test1_after.m === |
=== ml_test1_after.m === |
||
+ | <pre> |
||
− | |||
− | + | typ = 'W'; |
|
− | + | a=2; |
|
− | + | [V2,F2,R2,r2] = regpol(typ,a); |
|
+ | </pre> |
||
=== ml_test1_check.m === |
=== ml_test1_check.m === |
||
+ | <pre> |
||
− | switch lower(typ(1)) |
||
+ | switch lower(typ(1)) |
||
case 't' |
case 't' |
||
V=a^3/12*sqrt(2); |
V=a^3/12*sqrt(2); |
||
Zeile 69: | Zeile 71: | ||
R=a/4*sqrt(2*(5+sqrt(5))); |
R=a/4*sqrt(2*(5+sqrt(5))); |
||
r=a/2*sqrt((7+3*sqrt(5))/6); |
r=a/2*sqrt((7+3*sqrt(5))/6); |
||
− | + | end |
|
− | + | variable_names = {'V','F','R','r'}; |
|
− | + | variable_student = {V2,F2,R2,r2}; |
|
− | + | variable_tutor = {V,F,R,r}; |
|
− | + | for j=[1:numel(variable_names)] |
|
if check(variable_student{j},variable_tutor{j}) |
if check(variable_student{j},variable_tutor{j}) |
||
disp([variable_names{j},' richtig berechnet']); |
disp([variable_names{j},' richtig berechnet']); |
||
Zeile 81: | Zeile 83: | ||
disp([variable_names{j},' falsch berechnet']); |
disp([variable_names{j},' falsch berechnet']); |
||
end |
end |
||
− | + | end |
|
+ | </pre> |
||
+ | |||
+ | Mit der check.m funktion |
||
+ | === check.m === |
||
+ | |||
+ | <pre> |
||
+ | function result = check(a,b) |
||
+ | if abs(a-b) < 10*eps() |
||
+ | result = 1; |
||
+ | else |
||
+ | result = 0; |
||
+ | end |
||
+ | </pre> |
Version vom 3. November 2005, 13:51 Uhr
Inhaltsverzeichnis
Beispiel2
Projektverzeichnissname:
andrej.sommer2005.aufgabe2a
regpol.m
function [V,F,R,r]=regpol(typ,a) switch lower(typ(1)) case 't' V=a^3/12*sqrt(2); F=a^2*sqrt(3); R=a/4*sqrt(6); r=a/12*sqrt(6); case 'w' V=a^3; F=6*a^2; R=a/2*sqrt(3); r=a/2; case 'o' V=a^3/3*sqrt(2); F=2*a^2*sqrt(3); R=a/2*sqrt(2); r=a/6*sqrt(6); case 'd' V=a^3/4*(15+7*sqrt(5)); F=3*a^2*sqrt(5*(5+2*sqrt(5))); R=a/4*(1+sqrt(5))*sqrt(3); r=a/4*sqrt((50+22*sqrt(5))/5); case 'i' V=5*a^3/12*(3+sqrt(5)); F=5*a^2*sqrt(3); R=a/4*sqrt(2*(5+sqrt(5))); r=a/2*sqrt((7+3*sqrt(5))/6); end
ml_test1_after.m
typ = 'W'; a=2; [V2,F2,R2,r2] = regpol(typ,a);
ml_test1_check.m
switch lower(typ(1)) case 't' V=a^3/12*sqrt(2); F=a^2*sqrt(3); R=a/4*sqrt(6); r=a/12*sqrt(6); case 'w' V=a^3; F=6*a^2; R=a/2*sqrt(3); r=a/2; case 'o' V=a^3/3*sqrt(2); F=2*a^2*sqrt(3); R=a/2*sqrt(2); r=a/6*sqrt(6); case 'd' V=a^3/4*(15+7*sqrt(5)); F=3*a^2*sqrt(5*(5+2*sqrt(5))); R=a/4*(1+sqrt(5))*sqrt(3); r=a/4*sqrt((50+22*sqrt(5))/5); case 'i' V=5*a^3/12*(3+sqrt(5)); F=5*a^2*sqrt(3); R=a/4*sqrt(2*(5+sqrt(5))); r=a/2*sqrt((7+3*sqrt(5))/6); end variable_names = {'V','F','R','r'}; variable_student = {V2,F2,R2,r2}; variable_tutor = {V,F,R,r}; for j=[1:numel(variable_names)] if check(variable_student{j},variable_tutor{j}) disp([variable_names{j},' richtig berechnet']); else disp([variable_names{j},' falsch berechnet']); end end
Mit der check.m funktion
check.m
function result = check(a,b) if abs(a-b) < 10*eps() result = 1; else result = 0; end