"Index exceeds array dimensions. Index value 2 exceeds valid range [1-1] for array" --How to solve this?
Mostra commenti meno recenti
Whenever I am trying to update a 2-dimensional array in a loop matlab throws this error!
%% initialized in workspace
s.t(1)=0*0.1;
%% update via a function
for i=1:10 % implemented via simulink counter and increment block
func op= fcn(i)
s.t(i+1)=i*0.1
end
end
Risposta accettata
Più risposte (1)
Prudhvi Peddagoni
il 21 Ott 2020
Hi,
The error you mentioned occurs when you try to access an array element which is out of it's length.
If you are trying to update s.t array such that s.t(i+1)=i*0.1
s.t(1)=0*0.1;
for i=1:10
s.t(i+1)=i*0.1
end
if not, can you post more information about what you are trying to do
Hope this helps.
1 Commento
Sunandan Adhikary
il 21 Ott 2020
Modificato: Sunandan Adhikary
il 21 Ott 2020
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!