Matlab 실습 13. 버튼을 이용하여 색깔 설정하기
문제 : sin 함수의 색깔을 Box 버튼을 이용해 조절하는 프로그램을 작성해보자. 코드 : clear all, close all t=0:0.01:10; line_color=['r', 'b', 'g']; str='Yes'; while 1 if strcmp(str,'Yes') % str과 'Yes'가 같으면 1을반환 % s=menu('Choose a color', 'red', 'blue', 'green');... % 선택에 따라 s는 1,2,3을 반환 [s,tf]=listdlg('ListString',{'red','blue','green'}... ,'SelectionMode','single','PromptString','hello'); % menu와 동일 이걸 주로 사용 plot(t,sin(t),line_..
2022. 12. 24.
Matlab 실습 1. Step function
문제 : \( 2 \over s^2+2s+2 \)에 대한 단위계단응답을 구해보자. 코드 clc; clear all; clf t=0:0.01:5; Num=2; den=[1,2,2]; sys=tf(Num,den); Den=den'; A=Den(1) figure(1) [y,t]=step(sys,t); plot(t,y), grid figure(2) step(sys,t), grid 그래프 - 분자는 Num, 분모는 den이다.이때 계수만 행렬에 대입한다. - step을 이용하여 단위계단응답을 구할 수 있다. - [y,t]에 저장하고 plot을 사용하면 제목과 label이 비어있지만, step을 이용해 바로 출력하면 제목과 label이 생긴다.
2022. 12. 24.