matlab_classdef

Learning stuff 2012. 12. 12. 13:57

classdef


⦿Properties

- property definition block

- it can contain many properties

- ex)


properties

        R_sw1  = 0.003 %0.5;   % Turn-on resistance of the top MOSFET (ohm)

        R_sw2  = 0.003 %10;   % Turn-on resistance of the bottom MOSFET (ohm)

        R_sw3  = 0.003 %0.5;   % Turn-on resistance of the top MOSFET (ohm)

        R_sw4  = 0.003 %2;   % Turn-on resistance of the bottom MOSFET (ohm)

        R_l    = 0.0027 %0.083; % The ESR of the inductor L (ohm) Coiltronics CTX20-1-52M-R

        R_c    = 0.0765%0.05;  

        I_ctrl = 0.003 %2e-3;

        f_s    = 200000 %2e5;  % Switching frequency (Hz)

        Q_sw1  = 0.000000155 %5e-7; % Gate charges of the top MOSFET (F) (?)

        Q_sw2  = 0.000000155 %5e-8; % Gate charges of the bottom MOSFET (F) (?)

        Q_sw3  = 0.000000155 %5e-10; % Gate charges of the top MOSFET (F) (?)

        Q_sw4  = 0.000000155 %5e-10; % Gate charges of the bottom MOSFET (F) (?)

        L      = 0.000006; % Inductance (H)

         width; % Normalized gate width       

end


위에서 width 를 남겨놓은 이유는 정의 안하고 난중에 생성할때 줄꺼니까...


⦿methods

-method definition block

-Class definitions can contain multiple property definition blocks, each specifying different attribute settings that apply to the properties in that particular block

- 보통 Constructor 부터 시작을 한다

constructor의 예

ex)

methods

function obj = Converter(width) // 해당 classname 이 Converter이니까.... classname과 같은이름                                                        

가진  method는 constructor

            obj.R_sw1 = obj.R_sw1/width;

            obj.R_sw2 = obj.R_sw2/width;

            obj.R_sw3 = obj.R_sw3/width;

            obj.R_sw4 = obj.R_sw4/width;

            

            obj.Q_sw1 = obj.Q_sw1*width;

            obj.Q_sw2 = obj.Q_sw2*width;

            obj.Q_sw3 = obj.Q_sw3*width;

            obj.Q_sw4 = obj.Q_sw4*width;

        end %constructor Converter


그리고는 method 들을 정의 해 준다 쉽죠잉?

ex) 

function eff = eff_i_out(obj, v_in, v_out, i_out)

eff = zeros(size(v_in));


i_valid = and(v_in>0, v_out>0);

i_valid = and(i_valid, i_out>0);


v_in = v_in(i_valid);

v_out = v_out(i_valid);

i_out = i_out(i_valid);


p_conv = obj.converter(v_in,v_out,i_out);

p_out = v_out.*i_out;

eff_valid = p_out./(p_out+p_conv);


eff(i_valid) = eff_valid;

end


function p_converter = p_converter(obj, V_in_vec, V_out,vec, I_out_vec).............


여기서 신기한게 하나 있죠??


i_valid = and(v_in>0, v_out>0);

i_valid = and (i_valid, i_out>0);

요거.... ㅋㅋㅋㅋ

요거는 다음에ㅋㅋㅋ

'Learning stuff' 카테고리의 다른 글

Cache Optimization  (0) 2013.01.25
matlab index  (0) 2012.12.12
C++ 생성자  (0) 2012.12.12
matlab 관련 강의  (3) 2012.12.12
labview_2  (0) 2012.12.11