Index exceeds matrix dimensions. Error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Catalin
am 25 Sep. 2014
Kommentiert: Image Analyst
am 25 Sep. 2014
I get the error " Index exceeds matrix dimensions " when I test the function CharactOne bellow. However, I tested individually the second, forth and sixth line of code and they give good results. I don't understand what is the problem with the code, I am guessing it has to do with the if statement , but can't spot the mistake.
function CharactOne= CharactOne(baseType,TCType,u,T,paramsBase,paramsTC)
lambda=-1i*CharactExpLib(baseType,u,paramsBase)-u*CharactExpLib(baseType,-1i,paramsBase);
if strcmp(TCType,'G')|| strcmp(TCType,'IG')
CharactOne=CharactFunSLib(TCType,lambda,T,paramsTC);
else
CharactOne=CharactFunALib(TCType,lambda,T,paramsTC);
end
end
4 Kommentare
Adam
am 25 Sep. 2014
This is one of the many reasons I very rarely write a function nowadays without using validateattributes on every one of my input arguments. It takes very little time and cuts out so many silly errors later in the code.
Akzeptierte Antwort
Guillaume
am 25 Sep. 2014
You must have a variable called CharacterFactoryOne in your workspace.
newname = CharacterFactoryOne;
clear CharacterFactoryOne
3 Kommentare
Guillaume
am 25 Sep. 2014
Matlab was trying to access the element of the matrix CharacterFactoryOne at row baseType, column TCType, page u, etc., and that matrix didn't have that many element (and probably that many dimensions).
Image Analyst
am 25 Sep. 2014
But CharacterFactoryOne was not in the original code that was posted. I thought the problem was that the return argument was the same name as the function name itself (CharactOne).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!