Hey @william Smith
I understand you are trying to initialise few vectors with a pre-defined size. You can do so by using ‘zeros’ function which pre-allocates defined space by initialising the vector with zeroes.
Here's how you can create this setup:
% Time setup
dt = 0.01; % Time step (seconds)
tfinal = 1000; % Final time (seconds)
t = 0:dt:tfinal; % Time vector
% Preallocate variables
x = zeros(size(t)); % Position
x_dot = zeros(size(t)); % Velocity
x_ddot = zeros(size(t)); % Acceleration
theta = zeros(size(t)); % Angle (θ)
theta_dot = zeros(size(t)); % Angular velocity (θ̇)
theta_ddot = zeros(size(t)); % Angular acceleration (θ̈)
F = zeros(size(t)); % Force
% Initial condition
theta0 = deg2rad(10); % Example: initial angle of 10 degrees
theta(1) = theta0; % Set first value of theta
You can modify "dt" and "theta0" as needed. The "deg2rad" function is used to convert degrees to radians — this is optional depending on your unit preference.
More details on how to initialise a vector using “zeros” function can be found from the below documentation link:.
I hope this is beneficial!