MLTutorBeispielerstellung

Aus Physik
Version vom 3. November 2005, 13:47 Uhr von Golubkov (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

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