Subscripted assignment dimension mismatch
1 次查看(过去 30 天)
显示 更早的评论
I have the following algorithm and i keep getting an error, can anyone help?
for i = 1:nSlice
D1 = squeeze(IMs(:, :, i));
range = double(max(D1(:)));
norm_im = double(D1)/range;
level = graythresh(norm_im);
new_level = level*c_range;
BW = (D1>new_level);
IM_s(:,:,i) = BW(:); % error line
end
1 个评论
Geoff
2012-4-11
Please edit your question and format the code as 'code' (highlight and press the 'code' button on the toolbar. Also, on which line does the error occur?
采纳的回答
Geoff
2012-4-11
When you reference BW(:), it turns your matrix into a vector. Just do this:
IM_s(:,:,i) = BW;
Assuming that IM_s(:,:,i) is actually the same dimension as IMs(:,:,i)...
5 个评论
Geoff
2012-4-11
So, don't you want them to be the same dimension? I see you have accepted my answer, but have you resolved your problem?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!