Defining a symbol to perform a specified operation

1 visualización (últimos 30 días)
Aleem Andrew
Aleem Andrew el 20 de Abr. de 2020
Comentada: Aleem Andrew el 20 de Abr. de 2020
Is there a way, for example, given two numbers a and b I can either use a function or define a symbol, say %, such that a%b = (a*b)/(a+b)?

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 20 de Abr. de 2020
Aleem - I think the easiest approach would be to create a function. It would take the a and b as inputs, the function body would be your above equation, and the output parameter would be the result. Is there a reason why you want to create a function rather than just writng the above where needed?
  1 comentario
Aleem Andrew
Aleem Andrew el 20 de Abr. de 2020
I managed to use a function handle that takes two variables as input and returns xy/(x+y), although I was curious to know if this could be done by defining a symbol to perform the operation.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by