Étape 6: Code complet (original w / commentaires)
% retourne l’intelligence et l’inanité des énoncés selon la proximité au chat
intelligence % = m * x + b et rouge
inanité % = -m * x + b et bleu
d = abs (d’entrée (' Entrez la proximité au chat en pieds: ")) ;
Si d < 1
fprintf ('\nThis à proximité d’un chat, votre intelligence est negligible\nand l’inanité de vos déclarations est à un haut. \n")
DISP ('(nous vous ' RE A KITTY!)')
ElseIf d > = 20
fprintf ('\nThis loin d’être un chat, votre intelligence n’est pas défavorablement affected\nand l’inanité de vos déclarations est à un minimum. \n")
d’autre
Intelligence = 100/d-5 ;
inanité = -100/d + 105 ;
x = 20:-1:.01 ;
y = 100*(1./x) ;
intelligence %
Plot (x,-y + 105, « r »)
axe ([1 20 0 100])
Attends
inanité %
Plot (x, y-5, 'b')
légende ("Intelligence", 'L’inanité des bilans', 'localisation', 'meilleur')
Attends
point d’inanité %
terrain (d, intelligence, « bo »)
Attends
point d’intelligence %
terrain (d, inanité, « ro »)
xlabel ('proximité humaine au chat (pieds)")
ylabel('Magnitude')
fprintf ('\nAt cette intelligence de la gamme : \n\nYour est %d %% de la norm\nYour déclarations sont d % %% inane\n', floor(inanity), ceil(intelligence))
fin