Array indices must be positive integers or logical values
Ältere Kommentare anzeigen
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 Kommentar
Ankit
am 19 Sep. 2019
could you please post the complete code?
bvalue is missing.
Akzeptierte Antwort
Weitere Antworten (2)
madhan ravi
am 19 Sep. 2019
Bearbeitet: madhan ravi
am 19 Sep. 2019
0 Stimmen
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 Kommentare
madhan ravi
am 19 Sep. 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
am 19 Sep. 2019
Skydriver
am 19 Sep. 2019
0 Stimmen
Kategorien
Mehr zu Function Creation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!