why vectorize function is not recommended?

4 visualizaciones (últimos 30 días)
Osama Alkurdi
Osama Alkurdi el 28 de En. de 2021
Editada: Stephen23 el 27 de Mzo. de 2021
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 comentarios
Walter Roberson
Walter Roberson el 28 de En. de 2021
Also, long standing bug: vectorize changes quoted strings.
vectorize("ismember(A, {'+', '-', '*', '/', '^', '\'})")
ans = 'ismember(A, {'+', '-', '.*', './', '.^', '\'})'
Stephen23
Stephen23 el 29 de En. de 2021
Editada: Stephen23 el 27 de Mzo. de 2021
"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.

Iniciar sesión para comentar.

Respuestas (1)

Catalytic
Catalytic el 29 de En. de 2021
A warning without an explanation is not a real warning. I say you just ignore it.
  4 comentarios
Matt J
Matt J el 29 de En. de 2021
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 el 29 de En. de 2021
Editada: Adam Danz el 29 de En. de 2021
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.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by