필터 지우기
필터 지우기

Error In finding a variable inside a nested loop..

조회 수: 1 (최근 30일)
satish kumar
satish kumar 2020년 5월 7일
댓글: satish kumar 2020년 5월 7일
I am getting an error of "Operands to the || and && operators must be convertible to logical scalar values". Here, I need to plot figure(2), figure(3). i don't understand how to solve this. Any help is very much appreciated. I am attachhing my code here.
  댓글 수: 2
KSSV
KSSV 2020년 5월 7일
When code is run, it says undefined variable m.
satish kumar
satish kumar 2020년 5월 7일
Thanks again KSSV for the respone man. I just forgot to remove that 'm' . i don't need 'm' for now. I see an error in if conditional statement in the nested loop. i am updating my code here again. could you just check it.

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 7일
The code you posted cannot encounter that error unless you uncomment some code. If you do uncomment, then
elseif lambdat(:,:) > 0.34522 pi/2 - lambdam pi/2 + lambdam 0.34522 < lambdat(:,:) &&
What would be the intent of that code? MATLAB would parse it like
elseif lambdat(:,:) > 0.34522
pi/2 - lambdam
pi/2 + lambdam
0.34522 < lambdat(:,:) &&
complete with an error because the statement is not finished on the line.
Your lambdat is a non-scalar. When you test a non-scalar in an if or elseif the condition is only considered true if all of the values are non-zero . So if some of the lambdat values are > 0.34522 but not all of them are, then the condition would fail.
You should probably be using logical indexing, or else using a loop so you are only testing one value at a time.
  댓글 수: 1
satish kumar
satish kumar 2020년 5월 7일
Thanks a lot Walter Roberson, I will try to do that.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by