I would like to use a symbolic function in a for loop, however I spent hours reading the resources about symbolic functions and for loops and am still unable to figure out how I can go about doing this. My goal is to define the initial conditions of a particle (Position [x0 y0 z0] and Velocity [vx0 vy0 vz0]) and based on those, have the for loop calculate the position and velocity of the particle at previously defined time steps. This is all I have gotten started with on code:
syms x(t) y(t) z(t) vx(t) vy(t) vz(t)%Untis of cm/s
%Initial Conditions
s0 = [5 5 5];v0 = [-5E+8 0. -5E+8];x(0) = s0(1);y(0) = s0(2);z(0) = s0(3);vx(0) = v0(1);vy(0) = v0(2);vz(0) = v0(3);for t = 0:1E-10:10E-8 %Time step and interval
The reason I want to use a symbolic function for this is because position and velocity depend on time and I also want to add a function that randomly decides to change the velocity vector at a given time within the for loop. If anyone needs any more contextual information I will provide it as swiftly as possible, thanks.
Best Answer