~ in Matlab function
9 次查看(过去 30 天)
显示 更早的评论
I have some Matlab function call as
[Hz,~] = freqz(num, den, f, fsA)
What "~" means or what does it represent?
0 个评论
采纳的回答
dpb
2022-10-18
编辑:dpb
2022-10-18
It is a placeholder for the optional second argument but indicates to not assign to a variable -- in the above call, there is no reason to use it; it is the same as if had written
Hz = freqz(num, den, f, fsA);
the second output (and any/all subsequent) will just go to the bit bucket.
There would be reason to use it, and its raison d'etre would be if the expression were instead
[~,w] = freqz(num, den, f, fsA);
there it is the placeholder for the frequency response first output variable but for some reason that wasn't needed; only the second output, the angular frequency values were required. It saves creating unwanted/unneeded variable(s) in the workspace.
BTW -- This is a badly-named return variable in the original code; the first return argument from freqz is the response magnitude; 'Hz' implies a frequency; the third output variable is, in fact, the frequency vector in hertz.
PS. I know the syntax is in the doc somewhere, but one can't search for the single character punctuation and it isn't mentioned at all in the basics of function creation...so I never came across where that is.
6 个评论
Walter Roberson
2022-10-19
the @doc facility misses a number of things. For example you cannot even reference toolboxes by name.
dpb
2022-10-19
It also often lists many toolbox overloaded functions before the base product.
It's annoying it only works if click on with the mouse, typing more than the @ sign goes to name match and then tab won't/doesn't select the matched but have to go click on it, too...but it's still better than having to go open the full doc directly, just could be better...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!