Octave Atelier

코드와 해설을 함께 읽는 학습 문서

Code Detail

transient_cut

Signal Processing + Performance 중심의 Octave 학습 예제

course/basic/transient_cut.m

목록으로

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

카테고리

Course Basic

course-basic

코드 길이

21

lines

작성자

-

날짜 정보 없음

패키지

none

pkg load

함수 시그니처

function [idx, tt, yy, ff, Tr, dt, fs, df, nx] = transient_cut(t, y, t1, t2)

전체 코드

21 lines

function [idx, tt, yy, ff, Tr, dt, fs, df, nx] = transient_cut(t, y, t1, t2)
    # t: time vector
    # y: signal vector
    # t1: start time
    # t2: end time
    # tt: cut time vector
    # yy: cut signal vector

    idx = find(t >= t1 & t < t2);
    tt = t(idx) - t(idx(1));  # cut time vector
    yy = y(idx);  # cut signal vector
    
    dt = tt(2) - tt(1);  # sampling time
    nx = length(tt);  # number of samples
    Tr = nx * dt;  # total time
    df = 1 / Tr;  # frequency resolution
    fs = 1 / dt;  # sampling frequency
    ff = 0:df:df*(nx-1);  # frequency vector

end

코드 해설

목적

  • Signal Processing + Performance 중심의 Octave 학습 예제

입력

  • 파라미터: t
  • 파라미터: y
  • 파라미터: t1
  • 파라미터: t2

출력

  • 반환값: idx
  • 반환값: tt
  • 반환값: yy
  • 반환값: ff
  • 반환값: Tr
  • 반환값: dt
  • 반환값: fs
  • 반환값: df
  • 반환값: nx

실행 흐름

  1. 코드 상단부터 순차 실행

핵심 함수

  • tt
  • find
  • idx
  • length

실습 과제

  • 샘플링 주파수나 입력 주파수를 바꿔 스펙트럼 변화를 비교해보세요.
  • 핵심 함수 tt의 인자를 한 가지 바꿔 결과 변화를 기록해보세요.

같은 카테고리 코드

이전 코드 subplots 다음 코드 vertical