startup

Signal Processing + Control & Dynamics 중심의 Octave 학습 예제

course/optim/startup.m

코드 인덱스로 돌아가기

카테고리

Course Optimization

학습 소스 그룹

코드 길이

59

lines

작성자

-

날짜 정보 없음

패키지

io, signal, image, optim, splines

pkg load 기준

전체 코드

전체 코드를 복사해서 Octave에서 바로 실행할 수 있습니다.

clc; clear all; close all; 

pkg load io
pkg load signal
# pkg load statistics
pkg load image
pkg load optim
pkg load splines
# pkg load control
# pkg load symbolic

# 환경변수에 colored 함수 사용 가능함을 기록함
# strcmp(getenv("COLORTEXT"), "true")  % 사용할 떄
setenv("COLORTEXT", "true");  % 기록할 때

printf(fmt("{mfilename} local - project\n", "#FF5733"));

fontsize = 14;

color_base = [
    hex2color("#69A1FA"), % 파란색
    hex2color("#CF87DA"), % 보라색
    hex2color("#00CC6A"), % 녹색
    hex2color("#FADB79"), % 노란색
    hex2color("#5678C5"), % 조금 더 진한 파란색
    hex2color("#A84AC5"), % 깊은 보라색
    hex2color("#00B85A"), % 진한 녹색
    hex2color("#E5C441"), % 진한 노란색
    hex2color("#508BD1"), % 회색이 섞인 파란색
    hex2color("#9A59D7")  % 고급스러운 보라색
];

% figure
screenSize = get(0, "ScreenSize"); % [x y width height]
screenWidth = screenSize(3);
screenHeight = screenSize(4);
windowWidth = floor(screenWidth / 3);
windowHeight = floor(screenHeight / 3);
left = (screenWidth - windowWidth) / 2;
bottom = (screenHeight - windowHeight) / 2;
position = [left, bottom, windowWidth, windowHeight];

set(0, "defaultFigurePosition", position);
set(0, "defaultFigureName", "Figure");
set(0, "defaultFigureColor", "#FFFFFF");
set(0, "defaultFigureNumberTitle", "off");

% axes
set(0, "defaultAxesFontSize", fontsize);
set(0, "defaultAxesLineWidth", 0.5);
set(0, "defaultAxesXGrid", "on");
set(0, "defaultAxesYGrid", "on");
set(0, "defaultAxesZGrid", "on");
set(0, "defaultAxesColorOrder", color_base);
set(0, "defaultAxesNextPlot", "add");

% text
set(0, "defaultTextFontSize", fontsize);

코드 해설

목적

Signal Processing + Control & Dynamics 중심의 Octave 학습 예제

입력

  • 스크립트 상단에서 정의한 파라미터/입력 데이터를 사용합니다.

출력

  • 그래프/figure 출력
  • 콘솔 텍스트 출력

실행 흐름

  1. 데이터 준비
  2. 시각화
  3. 출력 및 저장

핵심 함수/주제

sethex2colorfloorscreenSizefmtgetgetenvprintf

실습 과제

  • 샘플링 주파수나 입력 주파수를 바꿔 스펙트럼 변화를 비교해보세요.
  • 질량/감쇠/강성 또는 전달함수 계수를 바꿔 응답 변화를 확인해보세요.
  • 초기값을 2~3개 바꿔 최적해 수렴 차이를 기록해보세요.

학습 팁

  • 그래프 비교 시 축 범위(XLim/YLim)와 단위를 먼저 고정하면 해석 오류를 줄일 수 있습니다.
  • 입력 파일 경로가 현재 작업 디렉터리 기준인지 먼저 확인하세요.

같은 카테고리의 다른 코드