Effacer les filtres
Effacer les filtres

Index exceeds the number of array elements (2).Please help ?

1 vue (au cours des 30 derniers jours)
S Priya
S Priya le 29 Juin 2021
Commenté : S Priya le 29 Juin 2021
h=1;
Ha=[-0.5;0.5]*h;
for i=1
h1=Ha('1,i');h2=Ha('2,i');
hnl=h2-h1;
end

Réponse acceptée

KSSV
KSSV le 29 Juin 2021
Modifié(e) : KSSV le 29 Juin 2021
Check your syntax. Indexing should be integers not strings. When you use ' ', this will be a string.
h=1;
Ha=[-0.5;0.5]*h;
for i=1
h1=Ha(1,i);
h2=Ha(2,i);
hnl=h2-h1;
end
  2 commentaires
Rik
Rik le 29 Juin 2021
I still dislike the choice Mathworks made when picking the name for the string datatype. The documentation is still littered with mentions of 'string' where they mean char array instead. When there wasn't a string datatype there wasn't any confusion.
In short, I have a meaningless correction for this answer: single quotes create a char, not a string.
S Priya
S Priya le 29 Juin 2021
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings 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