Error "Unbalanced or unexpected parenthesis or bracket"

17 vues (au cours des 30 derniers jours)
Mr_Turnip_Head
Mr_Turnip_Head le 12 Fév 2016
Modifié(e) : Roger Stafford le 12 Fév 2016
I'm just trying to add to the array of zeroes with this code:
%constants
h = .001 %Step Size
%Setting initial values
phi = 0;
i = 0;
A = zeros;
B = zeros;
C = zeros;
L = zeros;
%incrementing the variables
while i < 10
A[i] = (t[i+1] - t[i])/h;
B[i] = (r[i+1] - r[i])/h;
C[i] = (theta[i+1] - theta[i])/h;
L[i] = (phi[i+1] - phi[i])/h;
i = i + 1;
end
Except I get the error at "A[i]". Error "Unbalanced or unexpected parenthesis or bracket"

Réponses (1)

Roger Stafford
Roger Stafford le 12 Fév 2016
Modifié(e) : Roger Stafford le 12 Fév 2016
The brackets are your problem. For example, the line for A should read:
A(i) = (t(i+1) - t(i))/h;
However, after you have changed to parentheses you will get a different error because none of the four lines in the 'while' loop are defined for i = 0. i must be a positive integer.

Catégories

En savoir plus sur Mathematics 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