Why do I get the error message "Subscripted assignment dimension mismatch"?
显示 更早的评论
Subscripted assignment dimension mismatch.
Error in L1SR (line 144)
hIm(1:3, :) = bhIm(1:3, :);
Error in yima (line 60)
ReconIm = L1SR(lowIm, zooming, patch_size, overlap, Dh, Dl, lambda, regres);
Error in Research_Experiment (line 248)
res{2} = {yima(low{1}, upscaling)};
The highlighted Line (144) to Line (148) has these on code
hIm(1:3, :) = bhIm(1:3, :);
hIm(:, 1:3) = bhIm(:, 1:3);
hIm(end-2:end, :) = bhIm(end-2:end, :);
hIm(:, end-2:end) = bhIm(:, end-2:end);
Why do I have these errors ??
Thanks
采纳的回答
更多回答(1 个)
madhan ravi
2018-11-22
编辑:madhan ravi
2018-11-22
0 个投票
size(hIm(1:3, :)) and size( bhIm(1:3, :)) have to be the same to get rid of your error.
14 个评论
Chidiebere Ike
2018-11-22
编辑:Chidiebere Ike
2018-11-22
There are no comments in your code, no explanation of what it's doing. I doubt anybody is going to spend the time trying to decipher it.
In any case, the problem is simple. With:
hIm(1:3, :) = bhIm(1:3, :);
you're telling matlab to copy all the columns of rows 1 to 3 of bhIm into all the columns of rows 1 to 3 of hIm. As the error message tells, you they don't have the same number of columns. So of course, matlab doesn't know what to do. Should it drop some columns (which ones?) if hIm has less columns? Should it just invent some data to fill the mising columns if hIm has more columns?
If you were expecting the two variables to have the same number of columns, then you need to debug your program to find out why this is not so. If you were not expecting the two to have the same number of columns, then why were you intending to do with that copy operation?
Chidiebere Ike
2018-11-22
Guillaume
2018-11-22
I'm not sure what you mean by sharing the code. You've already shared the code above.
The problem is not our lack of access to the code, it's the lack of explanation that goes with it.
Chidiebere Ike
2018-11-22
Chidiebere Ike
2018-11-22
Walter Roberson
2018-11-22
One of the two arrays has a size that is proportional to the input zooming that we do not know the value of. The other of the two arrays is forced to be a multiple of 3 because of the imresize() by a factor of 3. It is not obvious to me that the number of columns should be the same.
Chidiebere Ike
2018-11-22
编辑:Chidiebere Ike
2018-11-22
Chidiebere Ike
2018-11-22
编辑:Chidiebere Ike
2018-11-22
Walter Roberson
2018-11-22
Only the resize with factor 3 is used for bhIm .
When your code stops in the debugger you should examine the size() of the variables on the left side and right side of the assignment statement.
Chidiebere Ike
2018-11-22
编辑:Chidiebere Ike
2018-11-22
Walter Roberson
2018-11-24
The L1SR code that you had in https://www.mathworks.com/matlabcentral/answers/425572-how-to-decrypt-a-mat-file#comment_627929 has the line
bhIm = imresize(lIm, zooming, 'bicubic');
whereas in this present code, you replaced zooming with 3. If it is left as zooming then there is no conflict with the rest of the code.
Chidiebere Ike
2018-11-24
编辑:Chidiebere Ike
2018-11-24
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!