clear; // *** パラメータ *** a = 1; b = 1; c = a * b; lambda = 1; k = 2 * %pi / lambda; f = 1; // *** 位置に関する周期関数 *** function phi_x = phi_x(x) // phi_x = a .* cos(2 * %pi / lambda .* x) phi_x = a .* exp(%i * k .* x) endfunction // *** 時間に関する周期関数 *** function phi_t = phi_t(t) // phi_t = b .* cos(2 * %pi * f .* t) phi_t = b .* exp(- %i * 2 * %pi * f .* t) endfunction // *** 進行波 *** function phi = traveling(x, t) phi = phi_x(x) .* phi_t(t) endfunction // *** 進行波の計算 *** X = linspace(0,1); T = linspace(0,1); [X2D, T2D] = ndgrid(X, T); PHI_travering = traveling(X2D, T2D); // *** 進行波のプロット *** xlabel("position, x"); ylabel("time, t"); zlabel("PHI(x,t)"); mesh(X2D, T2D, real(PHI_travering)); //surf(X2D, T2D, real(PHI_travering));