How do I write a while/loop function that will help me use a previous value to find the next value?

1 vue (au cours des 30 derniers jours)
Hi, so I'm writing a matlab code that deals with acceleration, velocity, and distance formulas. I use the acceleration to find the velocity. The acceleration and velocity to find the distance.
I also use the initial velocity to find the next velocity and the initial distance to find the next distance. I use a for loop that deals with i. "i" is the angle used in the acceleration equation.
My code right now is very bad. I'm not very good at matlab but I'm trying so bare with me. Here is my current code:
clc
clear all
g=9.81;
uk=.15;
t=0.01;
V=0;
S=0;
a=0;
R=3;
theta=0;
V=0;
while theta<90
for i=0:90
a(i)=g*cos(theta)-(uk*(g*sin(theta))+(V.^2/R));
a=a(i);
for i=0:90
V(i)=V+a(i)*t;
V=V(i);
S(i)=S+(V*t.^2)+(.5*a(i)*t.^2);
S=S(i);
for i=0:90
theta(i)=S/R;
theta=theta(i);
end
end
end
end

Réponses (1)

Walter Roberson
Walter Roberson le 5 Juin 2017

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by