Error using hilbert transform: "Subscript indices must either be real positive integers or logicals."
Mostra commenti meno recenti
Hello,
I have some troubles using hilbert transform for the enclosed vector in a guide.
The used command is:
y=abs(hilbert(A))/max(abs(hilbert(A)))
but Matlab sends the following error: "Subscript indices must either be real positive integers or logicals."
I can't understand why am i getting this error because i have already used this command in a former program successfully.
Any ideas please?
Risposte (1)
Walter Roberson
il 2 Ott 2015
1 voto
You accidentally assigned to a variable named "hilbert", which has the effect of overriding the meaning of hilbert() as a routine.
8 Commenti
Stephen23
il 2 Ott 2015
@F Z: you have define some variable with the same name as an inbuilt function. This is a common error that beginners make. It might be hilbert, max or abs. but because you did not give us the whole error message we cannot tell which of these it is. You need to read the error message and check your code.
Walter Roberson
il 2 Ott 2015
Please check that you have the Signal Processing Toolkit installed; you can check using ver()
Please report the result of
which -all hilbert
If it shows up then please show the code for your function.
Read your function definition again:
function Start_Callback(hilbert,...)
Do you see that you have defined a variable here with the name hilbert? When you use the name of an inbuilt function or variable it shadows the inbuilt function/variable, so the inbuilt one cannot be used. When you then try to use the function hilbert, it can only find the variable that you defined in your function definition, which is clearly a variable and thus clearly the code
hilbert(A)
is indexing a variable using A, and the values of A are somehow not suitable for indexing.
Solution: NEVER name your variable with the same name as an inbuilt function, e.g. size, length, i, j, cat, date, hilbert, etc. Before you use a variable name, use whose to check if it is already defined.
Muthu Annamalai
il 2 Ott 2015
Very prescient @Walter!
Walter Roberson
il 2 Ott 2015
We see this all the time. If it had been a case where the toolbox was not installed then the message would be about unknown variable or function.
Categorie
Scopri di più su Hilbert and Walsh-Hadamard Transforms in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!