필터 지우기
필터 지우기

??? Error using ==> eq Matrix dimensions must agree.

조회 수: 1 (최근 30일)
Giannakis Stoukas
Giannakis Stoukas 2015년 4월 15일
편집: Jan 2015년 4월 16일
orders are min_cost = min(x(:));
[pnode, node] = find(x == min_cost);
[row, column]=find(My_matrix == pnode);
[rows, columns]=find(My_matrix==node);
and i get this error
Error in ==> lisi_dokimes4 at 635
[row, column]=find(My_matrix
== pnode);
and the min_cost instead of taking one value it takes an array,x is a matrix 101X101 My_matrix has dimensions 10X14
  댓글 수: 3
Giannakis Stoukas
Giannakis Stoukas 2015년 4월 16일
I changed it here and i wrote it My_matrix instead of diadromes_final to understand what "diadromes_final" is.Diadromes_final is the matrix My_matrix.Where i have write My_matrix it is diadromes_final,but i forgot to change it in the error,so the error is
Error in ==> lisi_dokimes4 at 635 [row, column]=find(My_matrix == pnode);
Adam
Adam 2015년 4월 16일
You need to give clear full details of the sizes of every variable in the code snippet if you want help to solve this, otherwise we are just guessing at what might be the problem.
Given the line of the error, the following variables are all relevant:
x
min_cost
pnode
My_matrix
depending if the following line also has problems node may also be relevant.

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

답변 (1개)

Jan
Jan 2015년 4월 16일
편집: Jan 2015년 4월 16일
diadromes_final and pnode have different sizes. As long as you do not post the code, which creates these two variables, we do not have the chance to guess the reason for this. So I suggest to use the debugger and step through the code line by line to find out, where the different sizes are comming from.
[EDITED] So let me clarify your question:
min_cost = min(x(:))
[pnode, node] = find(x == min_cost);
[row, column] = find(My_matrix == pnode);
Now it is not clear, how x and my_matrix are connected. But the error message means, that pnode and My_matrix have different sizes. Why do you assume that both have the same size? Perhaps you want ismember instead of the == comparison?
  댓글 수: 4
Giannakis Stoukas
Giannakis Stoukas 2015년 4월 16일
Maybe the "==" isn't right and i have to use something else.In the problem i have a matrix x and a variable min_cost and i want to find in which row is the value (pnode) and in which column (pnode).After this,i have another matrix,My_matrix,and i want to find in which rows and columns are the pnode and node in the matrix My_matrix.
Jan
Jan 2015년 4월 16일
편집: Jan 2015년 4월 16일
And what should happen, if the minimal value appears multiple times in the matrix?
Please provide a relevant small example of the inputs and the wanted outputs. The description as text does nopt allow to create a useful answer.

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

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by