Subscripted assignment dimension mismatch

1 回表示 (過去 30 日間)
Mugo
Mugo 2012 年 4 月 11 日
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
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
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
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?
Mugo
Mugo 2012 年 4 月 12 日
Im happy with the solution to my initial error problem, but the dimension issue is a different thing im working on currently. I will post a new question if i cant figure it out. Thanks for your help...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by