필터 지우기
필터 지우기

why vectorize function is not recommended?

조회 수: 10 (최근 30일)
Osama Alkurdi
Osama Alkurdi 2021년 1월 28일
편집: Stephen23 2021년 3월 27일
can anyone explain to me in a simple way why vectorize function is not recommended, and how i can avoid any possible troubles from using it
and is there is a better way to do its functionality, please dont give me links, just explain to me in a simple way, thanks in advance.
  댓글 수: 12
Walter Roberson
Walter Roberson 2021년 1월 28일
Also, long standing bug: vectorize changes quoted strings.
vectorize("ismember(A, {'+', '-', '*', '/', '^', '\'})")
ans = 'ismember(A, {'+', '-', '.*', './', '.^', '\'})'
Stephen23
Stephen23 2021년 1월 29일
편집: Stephen23 2021년 3월 27일
"You missed one, Stephen, but it is quite obscure. The \ operator is vectorized as .\ also known as ldivide; "
No, as your own example clearly shows, the vectorize operator does not change that operator:
vectorize('a\b')
ans = 'a\b'
You missed looking at the output of your own example (above), which clearly shows that vectorize does NOT add a period in front of the backslash character.
You missed reading my previous comment, Walter Roberson, where I hinted that I had already looked at the code. And where I stated that that vectorize could be "trivially replaced with one regexprep call".
I did not "miss" that operator, because what I wrote replicates the behavior of vectorize.

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

답변 (1개)

Catalytic
Catalytic 2021년 1월 29일
A warning without an explanation is not a real warning. I say you just ignore it.
  댓글 수: 4
Matt J
Matt J 2021년 1월 29일
If no explanation implies the reason doesn't exist then, by the same logic, no explanation for the omission means the omission doesn't exist. So if the omission doesn't exist, maybe TMW feels than explanation was indeed given! :-)
Adam Danz
Adam Danz 2021년 1월 29일
편집: Adam Danz 2021년 1월 29일
Scroll to the bottom of the vectorize page and place a star rating which will allow you to type and submit feedback.
That feedback is received by MathWorks Gnomes which are never seen nor heard but visit the MathWorks documentation team at night while they are sleeping and whisper selected suggestions into their ears to manipulate their dreams. Occassionally this causes them to wake up with a Eureka moment that leads to changes in the documentation.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by