Matlab should introduce functions like ‘’abs2‘’
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Now matlab has only the function 'abs'.
In many case, I need not abs but abs2.
The function abs2 is a inbuilt function in julia as far as I know. It is very convenient.
2 comentarios
Dyuman Joshi
el 10 de Dic. de 2023
I don't see a point in doing that, when it is just abs(x).^2 or x.^2 (for real numbers).
If you do, you can write to The MathWorks explaining why they should be doing that as well - Contact Support > Create Service Request > Technical Support > Product help, bugs, suggestions or documentation errors.
Meanwhile, you can define and save a function named abs2() yourself and use it like it is built-in function -
abs2(-3)
abs2(2.5)
function y = abs2(x)
y = abs(x).^2;
end
John D'Errico
el 10 de Dic. de 2023
The beauty of any language, MATLAB included, is you can write such a function for your own use. Put it in your personal library of functions. Now you have extended MATLAB to work the way you want it to work. @Dyuman Joshi has already given you the code, in what should probably have been an answer. (I would STRONGLY recommend adding comments and help of course. But the code is there.
Yes, you can also put in a feature request directly to MathWorks. If abs2 is the greatest thing since sliced bread, then tell them! Don't bother telling us, as that does nothing.
Respuestas (0)
Ver también
Categorías
Más información sobre Waveform Design and Signal Synthesis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!