Subscript indices must either be real positive integers or logicals.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
shahin hashemi
il 14 Gen 2019
Commentato: shahin hashemi
il 14 Gen 2019
dear all
i have code like below
clc
clear all
for b=1:0.1:20
M((b*10)-9,:)=[1 1 1 ]
end
but at b=2.4 i got this error :
M =
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Subscript indices must either be real positive integers
or logicals.
Error in Untitled2 (line 4)
M((b*10)-9,:)=[1 1 1 ]
i really appreciated if some can help me y i get this error and what the solotions ?
3 Commenti
Stephen23
il 14 Gen 2019
"i really appreciated if some can help me y i get this error..."
"...and what the solotions ?"
Do not do calculations on floating point numbers and expect to get exact integer outputs. Write your code knowing that calculations on floating point numbers accumulate floating point error.
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!