How to create a better 3D Discrete Plot?

1 visualización (últimos 30 días)
Athanasios Paraskevopoulos
Athanasios Paraskevopoulos el 10 de Mzo. de 2024
Comentada: Voss el 10 de Mzo. de 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

Respuesta aceptada

Voss
Voss el 10 de Mzo. de 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 comentarios
Athanasios Paraskevopoulos
Athanasios Paraskevopoulos el 10 de Mzo. de 2024
Thank you very much for your help and your time!!!
Voss
Voss el 10 de Mzo. de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Networks en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by