탑배너 열기

 

자유게시판

Matlab 함수예제 N

No.5554039
  • 작성자 남강현
  • 등록일 : 2023.01.25 11:12
  • 조회수 : 518

function Plot_sine(Initial, Interval, Final, Type, Magnitude, Frequency, Phase)

set(0,'defaultUicontrolFontName','Times New Roman')

set(0,'defaultAxesFontName','Times New Roman')

set(0,'defaultTextFontName','Times New Roman')

set(0,'defaultUicontrolFontSize',15)

set(0,'defaultAxesFontSize',15)

set(0,'defaultTextFontSize',15)

t = Initial:Interval:Final;

w = 2*pi*Frequency;

Phi = Phase/(180/pi);

if  (Type==1)

    y = Magnitude*sin(w*t+Phi);

    figure(1),

    plot(t,y,'k-','Linewidth',2), hold on, grid on;

    xlabel('Time [sec]'), ylabel('Magnitude [m]'),

    legend('Sine function')

else if  (Type==2)

    y = Magnitude*cos(w*t+Phi);

    figure(2),

    plot(t,y,'r-','Linewidth',2), hold on, grid on;

    xlabel('Time [sec]'), ylabel('Magnitude [m]'),

    legend('Cosine function')

else

    x = Magnitude*sin(w*t+Phi);

    y = Magnitude*cos(w*t+Phi);

    figure(3),

    plot(x,y,'r-','Linewidth',2), hold on, grid on;

    xlabel('Time [sec]'), ylabel('Magnitude [m]'),

    legend('sine-cosine')

end

end

return