필터 지우기
필터 지우기

help me finding this error

조회 수: 1 (최근 30일)
monisha silvia
monisha silvia 2018년 3월 17일
댓글: Rik 2018년 3월 18일
Error using .* Matrix dimensions must agree.
Error in main (line 175) p = ((1-rho).*p + rho.*delta_p_current.*v).*delta_p_current + p.*(abs(1-delta_p_current));
  댓글 수: 2
Rik
Rik 2018년 3월 17일
The dimensions don't agree. You can't use an element-wise operation if the dimensions don't match.
Rik
Rik 2018년 3월 18일
How do you expect me to read the code you e-mailed me? Did you manually removed all line ends? I will not have any look at your code unless and until it is in a readable format. You should either post it here (edit your question and use the {}Code button), or attach the m-file. (don't forget to attach any necessary other files as well in a zip)
If you use the debugger to stop execution at that line, you will be able to see the dimensions of each variable so you can check if any are a size you don't expect.
Also, you should try to convert this to a MWE. Remove a much code as you can that doesn't affect the error. Doing that already helps you find the error, and if you don't find it, we will have less code to debug.

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2018년 3월 18일
The problem is that this line
temp = find(cumsum(ant_transit_prob)>=rand(1), 1);
sometimes returns an empty vector. I don't know what this algorithm is supposed to do, but you will have to change this line to make sure temp contains a valid value.
Also, the reading of the image should be changed to this:
% image loading
filename ='03';
img = rgb2gray(imread([filename '.jpg']));
[nrow, ncol] = size(img);
  댓글 수: 2
monisha silvia
monisha silvia 2018년 3월 18일
Error using .* Matrix dimensions must agree.
Error in main (line 175) p = ((1-rho).*p + rho.*delta_p_current.*v).*delta_p_current + p.*(abs(1-delta_p_current));
Rik
Rik 2018년 3월 18일
Just as with the previous function: imread returns a matrix with 3 dimension, while the rest of you code assumes a 2D matrix.
img=im2double(rgb2gray(im));

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

monisha silvia
monisha silvia 2018년 3월 18일
new to matlab. finding difficult to solve

카테고리

Help CenterFile Exchange에서 Biomedical Imaging에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by