フィルターのクリア

How do I plot the Hamiltonian (phase plot) of a 2d system

9 ビュー (過去 30 日間)
savitha muthanna
savitha muthanna 2021 年 9 月 10 日
編集済み: Ayush 2024 年 4 月 4 日
Hi
I have the Hamiltonian H(p,q). Both p and q are two dimensional arrays of size say (2,N). How do I plot q vs p? (p is derivative of q, but that I think is not important).
Thank you
Savitha

回答 (1 件)

Ayush
Ayush 2024 年 4 月 4 日
編集済み: Ayush 2024 年 4 月 4 日
Hi,
It seems you want to plot 2D arrays, where (p) and (q) are both two-dimensional arrays of size (2, N), implying you have two sets of data points to plot against each other. To do so, refer to an example implementation below for a better understanding:
% Number of data points
N = 100;
% Generate sample data for p and q
% Assuming p and q vary linearly for demonstration
% p = [p1; p2] and q = [q1; q2] where p1, p2, q1, q2 are 1xN arrays
p = [linspace(0, 10, N); linspace(5, 15, N)];
q = [linspace(0, 20, N); linspace(10, 30, N)];
% Plotting
figure; % Opens a new figure window
% Plot for first set of variables
subplot(1,2,1); % Subplot 1
plot(p(1,:), q(1,:), 'r-'); % Plots q1 vs p1 with red line
xlabel('p1');
ylabel('q1');
title('Plot of q1 vs p1');
grid on; % Adds grid for better visualization
% Plot for second set of variables
subplot(1,2,2); % Subplot 2
plot(p(2,:), q(2,:), 'b-'); % Plots q2 vs p2 with blue line
xlabel('p2');
ylabel('q2');
title('Plot of q2 vs p2');
grid on;

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by