Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

subscripted assignment dimension mismatch

조회 수: 2 (최근 30일)
Lakshmipriya S
Lakshmipriya S 2015년 9월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
Subscripted assignment dimension mismatch.
Error in guiast>pushbutton6_Callback (line 528) C(rowspan,colspan,1) = R1;
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in guiast (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)guiast('pushbutton6_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Here is the code
C(rowspan,colspan,1) = R1;
C(rowspan,colspan,2) = G1;
C(rowspan,colspan,3) = B1;

답변 (1개)

David Young
David Young 2015년 9월 3일
You do not say how rowspan and colspan are calculated, but the problem is that they do not match the size of R1 (or the other two arrays, probably). The solution depends on what you want. If rowspan and colspan are correct but you do not want the whole of R1, try
C(rowspan,colspan,1) = R1(rowspan, colspan);
% etc
assuming R1 is a 2-D matrix and rowspan and colspan represent a part of it.
If you want the whole of R1 etc. you can use
rowspan = 1:size(R1, 1);
colspan = 1:size(R2, 2);
to get the correct ranges.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by