problem1.


사용자정의 함수 파일

function kmL=mgTOkm(mpg)

kmL=mpg*1.609344/3.785412


명령창

>> mgTOkm(23);


kmL =


    9.7783


>> mgTOkm(50);


kmL =


   21.2572



problem2.


사용자정의 함수 파일

function [cm,kg]=STtoSI(in,ib)

cm=in*2.54;

kg=ib*0.453592;



명령창

>> [cm,kg]=STtoSI(11+5*12,181)


cm =


  180.3400



kg =


   82.1002




problem3


사용자정의함수

function y=prob3(x)

y=0.9.*x.^4.*exp(-0.1.*x)-15.*x.^2-5.*x;


  a)

명령창

>> prob3([-2,4])


ans =


  -32.4118 -105.5583



  b)

>> fplot('prob3',[-3,5])

>> xlabel('x'),ylabel('y')


figure




problem 4.   (솔루션 답이 틀린듯....?)


사용자정의함수

function ftps=kmphTOfts(kmh)

ftps=3280.8399*kmh/3600;


명령창


>> kmphTOfts(70)


ans =


   63.7941



problem 5.

사용자정의함수

function r=prob5(theta)

r=sin(3.*theta).*cos(theta);


 a) 명령창

>> format short e

>> prob5([pi/4 5*pi/2])


ans =


   5.0000e-01  -3.0616e-16



 b) 명령창

>> t=linspace(0,2*pi,100);

>> r=prob5(t);

>> polar(t,r)


figure



problem 6.


사용자정의함수

function [x,y]=maxmin(a,b,c)

x=-b/(2*a);

y=a*x^2+b*x+c;


명령창

>> [x,y]=maxmin(2,9,-20)


x =


   -2.2500



y =


  -30.1250


>> [x,y]=maxmin(-3,15,50)


x =


    2.5000



y =


   68.7500




problem 7. 


사용자정의함수

function M=amort(P,r,N)

M=P*(r/1200)/(1-(1+r/1200)^(-12*N));


명령창

>> format bank

>> M=amort(260000,6.75,15)


M =


       2300.76


problem 8.


script file

weight_of_ring=@ (R,r,d) R/4*pi^2*(2*r+d)*d^2;


weight=weight_of_ring(0.696, 0.6, 0.092)



명령창

>> format short

>> prob_weight_of_ring


weight =


    0.0188




problem 9.


사용자정의함수

function [area]=triangle(a,b,c)

s=(a+b+c)/2;

area=sqrt(s*(s-a)*(s-b)*(s-c));



명령창

>> Sa=triangle(10,15,7)


Sa =


   29.3939


>> Sb=triangle(6,8,10)


Sb =


    24


>> Sc=triangle(200,75,250)


Sc =


   6.2010e+03




problem 10.


사용자정의함수

function n=unitvec(A,B)

d=sqrt((A(1)-B(1))^2+(A(2)-B(2))^2+(A(3)-B(3))^2);

n=[((B(1)-A(1))/d), ((B(2)-A(2))/d), ((B(3)-A(3))/d)];  

 %단위벡터 구하기 -> 벡터를 벡터의 길이로 나눈다.



명령창

>> a=unitvec([-11 3 -2],[-13 -4 -5]);

>> b=unitvec([1.5 2.1 4],[11 15 9]);

>> c=unitvec([1 0 1],[0 1 1]);

>> a,b,c


a =


   -0.2540   -0.8890   -0.3810



b =


    0.5661    0.7686    0.2979



c =


   -0.7071    0.7071         0




problem 11.

사용자정의함수
function [r,th]=AddVecPol(r1,th1,r2,th2)
r=sqrt(r1^2+r2^2-2*r1*r2*cosd(180-th2+th1));
th=th1+acosd((r2^2-r^2-r1^2)/(-2*r*r1));


명령창
>> [r_a,th_a]=AddVecPol(5,23,12,40);
>> [r_b,th_b]=AddVecPol(6,80,15,125);
>> [r_a,th_a],[r_b,th_b]

ans =

   16.8451   35.0215


ans =

   19.7048  112.5663



problem 12.


사용자정의함수

function n=randint(a,b)

n=round((b-a)*rand+a);


명령창

>> randint(1,49)


ans =


    10


>> randint(-35,-2)


ans =


   -27



problem 13.



사용자정의함수

function d3=det3by3(A)

d3=A(1,1)*det2by2(A(2:3,2:3))-A(1,2)*det2by2(A(2:3,[1,3]))+A(1,3)*det2by2(A(2:3,1:2));


function d2=det2by2(X)

d2=X(1,1)*X(2,2)-X(1,2)*X(2,1);



명령창
>> A=[1 3 2; 6 5 4 ; 7 8 9];
>> B=[-2.5 7 1;5 -3 -2.6; 4 2 -1];
>> det_A=det3by3(A)

det_A =

   -39

>> det_B=det3by3(B)

det_B =

  -36.3000


problem 14.
a) 
  사용자 정의 함수
  function g=fgrade(R)
  g=(R(:,1)+R(:,2)+R(:,3)+R(:,4)+R(:,5)+R(:,6))*10/60+(R(:,7)+R(:,8)+R(:,9))*45/300+R(:,10)*45/100;


  명령창

  >> A=[8 9 6 10 9 8 76 86 91 80];

  >> g_A=fgrade(A)


  g_A =


     82.2833



오늘은 요기까지..긁적;;ㅋㅋ 뒤에껀 나중에 풀어야지..

+ Recent posts