MATLAB: Do I get this error

rectangular empty matrix

I get this error in the third line
"Improper assignment with rectangular empty matrix."
When I run this code
handles = guidata(hObject);
for j = 1:1:length(handles.cycleList)
maxStrain(j) = max(handles.graphEpsilon(handles.newHighPoints(j)+1:handles.newHighPoints(j+1)));
minStrain(j) = min(handles.graphEpsilon(handles.newHighPoints(j)+1:handles.newHighPoints(j+1)));
end
The length of cycleList is 740. The length of handles.newHighPoints is 778. I read several other forums but could not figure it out. Why am I getting this error?

Best Answer

  • My guess is that:
    handles.newHighPoints(j)+1
    is greater than:
    handles.newHighPoints(j+1)
    so the colon operator evaluates this as an empty vector (it will not decrement unless you tell it to), and the matrix evaluates as empty.
    Consider:
    v = 2:1
    evaluates to:
    v =
    Empty matrix: 1-by-0