Vector normalization giving error in second iteration

조회 수: 3 (최근 30일)
Sania Gul
Sania Gul 2019년 1월 2일
댓글: Sania Gul 2019년 1월 4일
In first iteration, there was no issue, but in second iteration, the program stopped running giving error " Subscript indices must either be real positive integers or logicals" .
See line 62
Matlab command
s1=s1/norm(s1)

채택된 답변

Jan
Jan 2019년 1월 2일
편집: Jan 2019년 1월 2일
You have redefined "norm" as a variable in:
norm = 1./eta;
Afterwards you cannot access the function norm() directly anymore. The solution is easy: Do not shadow built-in functiony by variables, but choose a different name for teh variable.
By the way: you can find the reason of such problems easily using the debugger. Type this in the command window:
dbstop if error
and run your code again. When Matlab stops at the problem, check the used expressions:
which norm -all % <- this will reveal the problem
size(s1) % <- might be useful in other cases
class(s1)
s1
  댓글 수: 1
Sania Gul
Sania Gul 2019년 1월 4일
thank u thank u thank u. I highly acknowledge ur support

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by