Info

This question is closed. Reopen it to edit or answer.

subscripted assignment dimension mismatch

1 view (last 30 days)
Lakshmipriya S
Lakshmipriya S on 3 Sep 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
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;

Answers (1)

David Young
David Young on 3 Sep 2015
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.

This question is closed.

Community Treasure Hunt

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

Start Hunting!