Cannot identify error in line of code
Afficher commentaires plus anciens
Hi everyone,
I'm trying to figure out why this line of code is ending up in error whenever I run the code. Is there something small I'm missing maybe? The error is in line 10 by the way.
Thank you!
EDIT: This is the error message:
">> Cnvalues
Index exceeds matrix dimensions.
Error in Cnvalues (line 15)
Cn12 = ((-CpAOA12(i+1)-CpAOA12(i))./2).*((xvec(i+1))-(xvec(i)));"

1 commentaire
Stephen23
le 17 Sep 2017
@Stenila Simon: please edit your question and do both of these things:
- Show the complete error. This means show us all of the red text. Do NOT use a screenshot: screenshots are useless for us.
- Show or upload your code. Do NOT use a screenshot: screenshots are useless for us.
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 17 Sep 2017
1 vote
Your initialization of sumCn4 should be before the loop.
Your maximum value for i should be at most min( length(cpAOA4) - 1, xvec - 1) so if those are length 54 then you should have "for i = 1 : 53"
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!