Borrar filtros
Borrar filtros

Help me with this code

2 visualizaciones (últimos 30 días)
Andrea Verardi
Andrea Verardi el 5 de Nov. de 2019
Comentada: darova el 5 de Nov. de 2019
Hi, I have a problem.
How can I use an output parameter from a function in a live script .mlx?
For example, how can I use the 'n' parameter in the Live Script from the following function?
function [n] = stat(x)
n = (x+1/x)
end
If I try to use it, the "Undefined Function or Variable 'n'." Error Message shows up.
I have a simple Live Script like this:
x = 3; % or other numbers of choice
stat(x);
n
I just need to be able to manipulate 'n' in the Live Script after the use of the function 'stat(x)'.
Thanks in advance for the assistance.

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 5 de Nov. de 2019
y=stat(x); % here n value reflects on y,
Or
You can keep the same output argument name, like
n=stat(x);
  2 comentarios
Andrea Verardi
Andrea Verardi el 5 de Nov. de 2019
thank you so match
darova
darova el 5 de Nov. de 2019
please accept the answer

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by