Clear Filters
Clear Filters

while loop error with conditional statment

1 view (last 30 days)
PetronasAMG on 19 Feb 2018
Answered: Basil C. on 19 Feb 2018
i %ignore this i code starts from below
interval = 1.2
x_int = 0:intereval:c
while x_int(i) <= c
ya(i) = ((5*c)*(TT/100))*((0.2969*sqrt(x_int(i)/c))-(0.126*(x_int(i)/c))-...
yb(i)= -((5*c)*(TT/100))*((0.2969*sqrt(x_int(i)/c))-(0.126*(x_int(i)/c))-...
Here c can be any whole number (assuming it's bigger than its interval). when i run this i get an error saying Index exceeds matrix dimensions. at while x_int(i) <= c Please help!

Answers (1)

Basil C.
Basil C. on 19 Feb 2018
OR you could just modify your WHILE loop condition as :
while (x_int(i) <= c && i<length(x_int))


Community Treasure Hunt

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

Start Hunting!