카테고리
Course Basiccourse-basic
코드와 해설을 함께 읽는 학습 문서
Code Detail
복소수와 폴라 플롯 (특수축)
course/basic/demo-11.m
코드를 복사해 Octave에서 바로 실행할 수 있습니다.
66 lines
# filename: demo-11.m
# writer: won sunggyu
# date: 2025-04-22
# language: octave
# description: 복소수와 폴라 플롯 (특수축)
#------------------------------------------------------------------------------
# 초기화
#------------------------------------------------------------------------------
# run("startup.m");
clc; clear all; close all;
printf(fmt("{mfilename}\n", "#FF5733"));
#------------------------------------------------------------------------------
# 데이터 준비
#------------------------------------------------------------------------------
# 파라메트릭 플롯1
th = linspace(0, 2 * pi, 32 + 1);
rr = abs(sin(2 * th));
x1 = rr .* cos(th);
y1 = rr .* sin(th);
# 파라메트릭 플롯2
x2 = 16 * power(sin(th), 3);
y2 = 13 * cos(th) - 5 * cos(2 * th) - 2 * cos(3 * th) - cos(4 * th);
# 개별 복소수 목록
c0 = complex(0, 0);
c1 = 0.5 * exp(1j * 0.1);
c2 = 0.5 * exp(1j * 1.0);
carr = [c0, c1, c2];
#------------------------------------------------------------------------------
# 데이터 연산
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# 그래프 그리기
#------------------------------------------------------------------------------
# 그래프
figured("Size", [960, 960], "Move", [-1280, 0], "Name", mfilename);
ax1 = subplots(2, 2);
# polar() 함수의 결과에서 cli-fltk 모드에서 polar axes 지원 안함
# axes 옵션 중에 비호환 항목 있음 (예: NextPlot, add, Xlabel, Ylabel)
polar(ax1(1, 1), th, rr)
hold on
polar(ax1(1, 1), arg(carr), abs(carr))
plot(ax1(1, 2), x1, y1)
hold on
plot(ax1(1, 2), real(carr), imag(carr))
plot(ax1(2, 2), x2, y2)
set(ax1(1, 2), "DataAspectRatio", [1, 1, 1], "Xlabel", "x", "Ylabel", "y")
set(ax1(2, 2), "DataAspectRatio", [1, 1, 1], "Xlabel", "x", "Ylabel", "y")