How to declare function?

1 visualización (últimos 30 días)
Mustafa Alper YILDIZ
Mustafa Alper YILDIZ el 21 de Oct. de 2013
Comentada: Mustafa Alper YILDIZ el 21 de Oct. de 2013
I'm trying to understand declaration of functions in Matlab. I want to compute
y(x)=x(sqrt(x)-sqrt(x-1)) for x= 10; 100; 1000;
And after declaring it as a function(.m) how can I call this function?
Thanks in advance

Respuesta aceptada

sixwwwwww
sixwwwwww el 21 de Oct. de 2013
Editada: sixwwwwww el 21 de Oct. de 2013
Dear Mustafa,
function y = calculate_sqrt(x)
y = x .* (sqrt(x) - sqrt(x - 1));
end
you can save it with the name "calculate_sqrt.m"
and then later you call it as
x = [10 100 1000];
y = calculate_sqrt(x);
I hope it helps. Good luck!
  1 comentario
Mustafa Alper YILDIZ
Mustafa Alper YILDIZ el 21 de Oct. de 2013
Thanks a lot. I got the idea :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by