how to solve 'Error using | Matrix dimensions must agree. ' ?

Hello Dears
i have the error that i mentioned in question and i do not know how i can solve it.
while (Lia2_One_Three ~= zeros(length(Lia2_One_Three),1) | Lia2_Two_Three ~= zeros(length(Lia2_Two_Three),1))
row_n2_three_step = randperm(length(area_2) / 2, n2_three_step_delayed_measurements) ;
Lia2_One_Three = ismember(row_n2_one_step, row_n2_three_step) ;
Lia2_Two_Three = ismember(row_n2_two_step, row_n2_three_step) ;
end
it seems that this error says that 'Lia2_One_Three ~= zeros(length(Lia2_One_Three)) ' and
' Lia2_Two_Three ~= zeros(length(Lia2_Two_Three))' should have same dimention. i just want to say that while the first condition or second condition is true, produce ' row_n2_three_step' again.
'Lia2_One_Three ' and ' Lia2_Two_Three ' are vectors with different dimentions.

댓글 수: 4

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 18일
편집: KALYAN ACHARJYA 2019년 6월 18일
OK, If the code is small, can you share the complete code, so that we can try on it?
please see 108 to 112 rows
Thank you Dear

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

 채택된 답변

James Tursa
James Tursa 2019년 6월 18일
편집: James Tursa 2019년 6월 18일
Maybe this line:
while (Lia2_One_Three ~= zeros(length(Lia2_One_Three),1) | Lia2_Two_Three ~= zeros(length(Lia2_Two_Three),1))
could be this instead?
while ( any(Lia2_One_Three(:)) || any(Lia2_Two_Three(:)) )
I'm guessing a bit on what I think you want the test to do.
Note that the ~= and | operators are element-wise operators, which I am guessing is not what you really want to use here.

댓글 수: 5

exactly you are right.
but can you please explain the code you have written a little more?
i want to say that when ' Lia2_One_Three' or 'Lia2_Two_Three' is not zero, stay in while loop and produce 'row_n2_three_step' untill both 'Lia2_One_Three' and 'Lia2_Two_Three' get zero.
'Lia2_One_Three' and 'Lia2_Two_Three' are vectors with different dimentions
should not we write :
while ( any(Lia2_One_Three(:) ~= 0) || any(Lia2_Two_Three(:) ~= 0) )
The any( ) functions tests for nonzeros, so the ~=0 part in your proposed code is redundant.
thanks a lot

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

질문:

2019년 6월 18일

댓글:

2019년 6월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by