Filter löschen
Filter löschen

How to create a better 3D Discrete Plot?

2 Ansichten (letzte 30 Tage)
Athanasios Paraskevopoulos
Athanasios Paraskevopoulos am 10 Mär. 2024
Kommentiert: Voss am 10 Mär. 2024
I am study the Discrete Klein-Gordon Equation.
By interpreting the equation in this way, we can relate the dynamics described by the discrete Klein - Gordon equation to the behavior of DNA molecules within a biological system . This analogy allows us to understand the behavior of DNA in terms of concepts from physics and mathematical modeling . Is ti possivle to I create a nicer 3D plot than the following?
% Parameters
numBases = 100; % Number of base pairs
kappa = 0.1; % Elasticity constant
omegaD = 0.2; % Frequency term
beta = 0.05; % Nonlinearity coefficient
% Initial conditions
initialPositions = 0.01 + (0.02 - 0.01) * rand(numBases, 1);
initialVelocities = zeros(numBases, 1);
% Time span for the simulation
tSpan = [0 50];
% Differential equations function
odeFunc = @(t, y) [y(numBases+1:end); ... % velocities
kappa * ([y(2); y(3:numBases); 0] - 2 * y(1:numBases) + [0; y(1:numBases-1)]) + ...
omegaD^2 * (y(1:numBases) - beta * y(1:numBases).^3)]; % accelerations
% Solve the system numerically
[T, Y] = ode45(odeFunc, tSpan, [initialPositions; initialVelocities]);
% Specific time points for visualization
timePoints = [0, 10, 20, 30, 40, 50];
% Initialize the figure for 3D plot
figure;
hold on;
% Plotting the dynamics in 3D
for i = 1:length(timePoints)
time = timePoints(i);
[~, timeIndex] = min(abs(T - time)); % Find the index of the closest time in T
displacements = Y(timeIndex, 1:numBases); % Displacement values at this time point
% Plotting each base pair displacement as a line in 3D space
plot3(1:numBases, repmat(time, 1, numBases), displacements, 'LineWidth', 2);
end
hold off;
xlabel('Base Pair');
ylabel('Time');
zlabel('Displacement');
title('3D Plot of DNA Base Pair Displacements Over Time');
view(3); % Adjust the view to see the plot in 3D

Akzeptierte Antwort

Voss
Voss am 10 Mär. 2024
Maybe a surface? Something like this:
% Parameters
numBases = 100; % Number of base pairs
kappa = 0.1; % Elasticity constant
omegaD = 0.2; % Frequency term
beta = 0.05; % Nonlinearity coefficient
% Initial conditions
initialPositions = 0.01 + (0.02 - 0.01) * rand(numBases, 1);
initialVelocities = zeros(numBases, 1);
% Time span for the simulation
tSpan = [0 50];
% Differential equations function
odeFunc = @(t, y) [y(numBases+1:end); ... % velocities
kappa * ([y(2); y(3:numBases); 0] - 2 * y(1:numBases) + [0; y(1:numBases-1)]) + ...
omegaD^2 * (y(1:numBases) - beta * y(1:numBases).^3)]; % accelerations
% Solve the system numerically
[T, Y] = ode45(odeFunc, tSpan, [initialPositions; initialVelocities]);
% Specific time points for visualization
timePoints = [0, 10, 20, 30, 40, 50];
% Initialize the figure for 3D plot
figure;
% Plotting the dynamics in 3D
[~, timeIndex] = min(abs(T - timePoints),[],1); % Find the index of the closest time in T
surf(1:numBases, repmat(timePoints(:), 1, numBases), Y(timeIndex, 1:numBases), ...
'EdgeColor', 'none', 'FaceColor', 'interp')
box on;
xlabel('Base Pair');
ylabel('Time');
zlabel('Displacement');
title('3D Plot of DNA Base Pair Displacements Over Time');
view(3); % Adjust the view to see the plot in 3D
  4 Kommentare
Athanasios Paraskevopoulos
Athanasios Paraskevopoulos am 10 Mär. 2024
Thank you very much for your help and your time!!!
Voss
Voss am 10 Mär. 2024
You're welcome!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by