Filter löschen
Filter löschen

Vector normalization giving error in second iteration

1 Ansicht (letzte 30 Tage)
Sania Gul
Sania Gul am 2 Jan. 2019
Kommentiert: Sania Gul am 4 Jan. 2019
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)

Akzeptierte Antwort

Jan
Jan am 2 Jan. 2019
Bearbeitet: Jan am 2 Jan. 2019
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

Weitere Antworten (0)

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by