demo-03a
(번외) 베셀 함수 구경하기
course/basic/demo-03a.m
전체 코드
전체 코드를 복사해서 Octave에서 바로 실행할 수 있습니다.
# filename: demo-03a.m
# writer: won sunggyu
# date: 2025-04-22
# language: octave
# description: (번외) 베셀 함수 구경하기
#------------------------------------------------------------------------------
# 초기화
#------------------------------------------------------------------------------
run("startup.m");
printf(fmt("{mfilename}\n", "#FF5733"));
#------------------------------------------------------------------------------
# 데이터 준비
#------------------------------------------------------------------------------
dx = 0.1;
nx = 1000;
x = 0:dx:dx*(nx-1);
#------------------------------------------------------------------------------
# 데이터 연산
#------------------------------------------------------------------------------
# 베셀 함수 (4종, 1-4차)
Jn = zeros(4, nx); # Bessel function of the first kind (Jₙ(x))
Yn = zeros(4, nx); # Bessel function of the second kind (Yₙ(x))
In = zeros(4, nx); # Bessel function of the third kind (Iₙ(x))
Kn = zeros(4, nx); # Bessel function of the fourth kind (Kₙ(x))
for i=1:4
Jn(i, :) = besselj(i, x);
Yn(i, :) = bessely(i, x);
In(i, :) = besseli(i, x);
Kn(i, :) = besselk(i, x);
end
Yn = Yn / max(max(abs(Yn)));
In = In / max(max(abs(In)));
Kn = Kn / max(max(abs(Kn)));
#------------------------------------------------------------------------------
# 그래프 그리기
#------------------------------------------------------------------------------
# 그래프
figured("Size", [1920, 960], "Move", [0, 0], "Name", mfilename);
ax = subplots(4, 4);
plot(ax(1, 1), x, Jn(1, :));
plot(ax(2, 1), x, Jn(2, :));
plot(ax(3, 1), x, Jn(3, :));
plot(ax(4, 1), x, Jn(4, :));
plot(ax(1, 2), x, Yn(1, :));
plot(ax(2, 2), x, Yn(2, :));
plot(ax(3, 2), x, Yn(3, :));
plot(ax(4, 2), x, Yn(4, :));
plot(ax(1, 3), x, In(1, :));
plot(ax(2, 3), x, In(2, :));
plot(ax(3, 3), x, In(3, :));
plot(ax(4, 3), x, In(4, :));
plot(ax(1, 4), x, Kn(1, :));
plot(ax(2, 4), x, Kn(2, :));
plot(ax(3, 4), x, Kn(3, :));
plot(ax(4, 4), x, Kn(4, :));
title(ax(1, 1), "Bessel Function of the First Kind (J₀(x))");
title(ax(2, 1), "Bessel Function of the First Kind (J₁(x))");
title(ax(3, 1), "Bessel Function of the First Kind (J₂(x))");
title(ax(4, 1), "Bessel Function of the First Kind (J₃(x))");
title(ax(1, 2), "Bessel Function of the Second Kind (Y₀(x))");
title(ax(2, 2), "Bessel Function of the Second Kind (Y₁(x))");
title(ax(3, 2), "Bessel Function of the Second Kind (Y₂(x))");
title(ax(4, 2), "Bessel Function of the Second Kind (Y₃(x))");
title(ax(1, 3), "Bessel Function of the Third Kind (I₀(x))");
title(ax(2, 3), "Bessel Function of the Third Kind (I₁(x))");
title(ax(3, 3), "Bessel Function of the Third Kind (I₂(x))");
title(ax(4, 3), "Bessel Function of the Third Kind (I₃(x))");
title(ax(1, 4), "Bessel Function of the Fourth Kind (K₀(x))");
title(ax(2, 4), "Bessel Function of the Fourth Kind (K₁(x))");
title(ax(3, 4), "Bessel Function of the Fourth Kind (K₂(x))");
title(ax(4, 4), "Bessel Function of the Fourth Kind (K₃(x))"); 코드 해설
목적
(번외) 베셀 함수 구경하기
입력
- 스크립트 상단에서 정의한 파라미터/입력 데이터를 사용합니다.
출력
- 그래프/figure 출력
- 콘솔 텍스트 출력
실행 흐름
- 초기화
- 데이터 준비
- 데이터 연산
- 베셀 함수 (4종, 1-4차)
- 그래프 그리기
- 그래프
핵심 함수/주제
axKindplottitlemaxInJnKn
실습 과제
- 질량/감쇠/강성 또는 전달함수 계수를 바꿔 응답 변화를 확인해보세요.
- 축 범위와 라벨을 바꿔 그래프 해석성이 어떻게 달라지는지 확인해보세요.
- 핵심 함수 ax의 인자를 한 가지 바꿔 결과 변화를 기록해보세요.
학습 팁
- 그래프 비교 시 축 범위(XLim/YLim)와 단위를 먼저 고정하면 해석 오류를 줄일 수 있습니다.
같은 카테고리의 다른 코드
- colored
course/basic/colored.m - demo-00
course/basic/demo-00.m - demo-01
course/basic/demo-01.m - demo-02
course/basic/demo-02.m - demo-03b
course/basic/demo-03b.m - demo-04
course/basic/demo-04.m - demo-05
course/basic/demo-05.m - demo-06
course/basic/demo-06.m - demo-07
course/basic/demo-07.m - demo-08a
course/basic/demo-08a.m