Array indices must be positive integers or logical values
Mostrar comentarios más antiguos
I have a problem to develop my coding. Here is my coding:
Mag=(6.5:0.1:9.5);
beta = bvalue * log(10);
MomentRate = (SM * 1e9)*(A*1e6)*(S/1000); MR=MomentRate;
for i = length(Mag)
N(i) = MR*(1.5-bvalue)*(1-exp(-beta*(M-Mag(i))))/(bv*Mo*exp(-beta(M-Mag(i))));
end
The problem is Array indices must be positive integers or logical values.
Let me how to solve my problem.
Thank you
Muktaf
1 comentario
Ankit
el 19 de Sept. de 2019
could you please post the complete code?
bvalue is missing.
Respuesta aceptada
Más respuestas (2)
madhan ravi
el 19 de Sept. de 2019
Editada: madhan ravi
el 19 de Sept. de 2019
0 votos
beta Operator missing here ( M
Note: Don’t name a variable beta because there is an inbuilt function named beta(). Preallocate N. The loop iterator should run from 1:length(...) (but I prefer numel() over length). Likely the loop is not necessary.
2 comentarios
madhan ravi
el 19 de Sept. de 2019
Without loop it’s simply:
N = MR*(1.5-bvalue)*(1-exp(-Beta*(M-Mag)))./(bv*Mo*exp(-Beta operator missing here (M-Mag)));
Skydriver
el 19 de Sept. de 2019
Skydriver
el 19 de Sept. de 2019
0 votos
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!