plot(x,y,LineSpec) 선 스타일: -, --, :, -. 마커: +, o, *, ., x, s, d 색: r, g, b, c, m, y, k, w
x에 대해 y 플로팅 (LineSpec은 선택 사항) LineSpec은 문자열로 표현된 linestyle, marker, color의 조합입니다. 예: "-r" = 마커 없는 빨간색 실선
title("Title")
플롯 제목 추가
legend("1st", "2nd")
좌표축에 범례 추가
x/y/zlabel("label")
x/y/z 축 레이블 추가
x/y/zticks(ticksvec)
x/y/z 축 눈금 가져오기 또는 설정
x/y/ztickangle(angle)
x/y/z 축 눈금 레이블 회전
x/y/zlim
x/y/z 축 범위 가져오기 또는 설정
axis(lim), axis style
축 제한 및 스타일 설정
text(x,y,"txt")
텍스트 추가
grid on/off
축 그리드 표시
hold on/off
새 플롯을 추가할 때 현재 플롯 유지
subplot(m,n,p), tiledlayout(m,n)
타일 형식 위치로 좌표축 생성
yyaxis left/right
두 번째 y축 생성
figure
Figure 창 생성
gcf, gca
현재 Figure 가져오기, 현재 축 가져오기
clf
현재 Figure 지우기
close all
열려 있는 Figure 닫기
테이블
table(var1,...,varN)
변수 var1, ..., varN이 있는 데이터로 테이블 생성
readtable("file")
파일에서 테이블 생성
array2table(A)
숫자형 배열을 테이블로 변환
T.var
변수 var에서 데이터 추출
T(rows,columns), T(rows,["col1","coln"])
T에 지정된 행과 열로 새 테이블 생성
T.varname=data
T의 (새) 열에 데이터 할당
T.Properties
T의 속성에 액세스
categorical(A)
categorical형 배열 생성
summary(T), groupsummary
테이블 요약 출력
join(T1, T2)
공통 변수로 테이블 조인
작업 (라이브 편집기)
라이브 편집기 작업은 일련의 특정 작업을 대화형 방식으로 수행하기 위해 라이브 스크립트에 추가할 수 있는 앱입니다. 작업은 일련의 MATLAB 명령을 나타냅니다. 작업이 실행하는 명령을 보려면 생성된 코드를 표시하면 됩니다.
데스크탑 툴스트립의 라이브 편집기 탭에서 사용할 수 있는 일반적인 작업은 다음과 같습니다.
누락된 데이터 정리
변화 지점 찾기
추세 제거
이상값 정리
국소 극값 찾기
데이터 평활화
프로그래밍 방법
함수
% Save your function in a function file or at the end
% of a script file. Function files must have the
% same name as the 1st functionfunction cavg = cumavg(x) %multiple args. possible
cavg=cumsum(x)./(1:length(x)) ;
end
익명 함수
% defined via function handles
fun = @(x) cos(x.^2)./abs(3*x);
제어 구조
if, elseif, 조건문
if n<10
disp("n smaller 10")
elseif n<=20
disp("n between 10 and 20")
else
disp("n larger than 20")
Switch Case 구문
n = input("Enter an integer: ");
switch n
case -1
disp("negative one")
case {0,1,2,3} % check four cases together
disp("integer between 0 and 3")
otherwise
disp("integer value outside interval [-1,3]")
end % control structures terminate with end
For 루프
% loop a specific number of times, and keep
% track of each iteration with an incrementing
% index variablefor i = 1:3
disp("cool");
end% control structures terminate with end
While 루프
% loops as long as a condition remains true
n = 1;
nFactorial = 1;
while nFactorial < 1e100
n = n + 1;
nFactorial = nFactorial * n;
end% control structures terminate with end