• Remix
  • Share
  • New Entry

on 9 Oct 2024
  • 11
  • 129
  • 0
  • 0
  • 738
Cite your audio source here (if applicable): https://pixabay.com/sound-effects/slow-moving-car-2-26762/
drawframe(1);
Write your drawframe function below
function drawframe(i)
% Parameters for the Lorenz system
sigma = 10;
rho = 28;
beta = 8/3;
% Initial condition
initialCondition = [1, 1, 1];
% Time span for the simulation
totalFrames = 4800;
tSpan = linspace(0, 100, totalFrames);
% Solve the Lorenz system using ode45
[~, sol] = ode45(@(t, y) lorenzSystem(t, y, sigma, rho, beta), tSpan, initialCondition);
% Create a figure for the animation
persistent fig h
if isempty(fig) || ~isvalid(fig)
fig = figure;
plot3(sol(:,1), sol(:,2), sol(:,3), 'k', 'LineWidth', 0.5); % Plot trajectory
hold on;
h = plot3(sol(1,1), sol(1,2), sol(1,3), 'k', 'LineWidth', 3,'Color',[0.0, 0.0, 0.502]);
title('Lorenz System Animation');
axis off;
view(0, 0);
end
% Ensure the frame number is within bounds
% j = i*10;
j = mod(i*10+(2200:1:2220),9600);
% Update the position of the point in the plot
set(h, 'XData', sol(j,1), 'YData', sol(j,2), 'ZData', sol(j,3));
drawnow;
function dydt = lorenzSystem(~, y, sigma, rho, beta)
% Lorenz system equations
dydt = zeros(3,1);
dydt(1) = sigma * (y(2) - y(1));
dydt(2) = y(1) * (rho - y(3)) - y(2);
dydt(3) = y(1) * y(2) - beta * y(3);
end
end
Movie
Audio
Remix Tree