understanding the meaning of a part of a code

1 回表示 (過去 30 日間)
Mohammed Qahosh
Mohammed Qahosh 2020 年 5 月 5 日
コメント済み: Mohammed Qahosh 2020 年 5 月 6 日
Hi everyone,
Could anyone help me to understand the meaning of the following sentence from a code. Thanks in advance for your help.
zci = @(v) find( v(1:end-1).*circshift(v(2:end), [-1 0]) <= 0)

採用された回答

S. Walter
S. Walter 2020 年 5 月 5 日
Mohammed,
What you wrote there is a function that you're storing in zci. The at sign (@) tells Matlab you're about to give a variable (or multiple variables) and declare how those variables will be used in a function.
Once you have declared zci, you should be able to input values, such as:
zci(-1:0.1:0)
which would result in an answer of 10.
The function that's being declared takes your variable, v, that you're passing to it, performs an operation, and finds where that's less than or equal to 0.
Hope that helps!
  1 件のコメント
Mohammed Qahosh
Mohammed Qahosh 2020 年 5 月 6 日
Dear Walter,
Thanks for the explanation. Now, I have the big picture and I can go through details to understand the rest.
Thanks again for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by