Successfully implement harmonic oscillator phase plot
이전 댓글 표시
I'm trying to implement this first order ODE:
This is the current code I have written:
%set up the requirements
xval = linspace(-5, 5, 20);
vval = linspace(-5, 5, 20);
[x, v] = meshgrid(xval, vval);
dotx = NaN(size(x));
dotv = NaN(size(v));
%phase map
for i = 1:numel(x)
dotx(i) = v(i);
dotv(i) = -x(i); %<--- not sure about this!
end
close all;
figure;
quiver(x, v, dotx, dotv, 'red');
axis equal manual;
xlabel('x(t)');
ylabel('v(t)');
title('Harmonic Oscillator');
However, I'm not sure if the phase map part is correct. Comments / suggestions?
Thanks
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!