Borrar filtros
Borrar filtros

How to go about programming this function in MatLab

1 visualización (últimos 30 días)
t sizzle
t sizzle el 20 de Abr. de 2021
Comentada: Rena Berman el 6 de Mayo de 2021
I am trying to program a function into matlab but I am struggling to get started. I want to program it as a function and not as part of a script so that I may use it later on when I need it.
Basicaly, there will be n number of terms, and x and y are arrays that will change in size depending on how have set them up.
  2 comentarios
Stephen23
Stephen23 el 28 de Abr. de 2021
Editada: Stephen23 el 28 de Abr. de 2021
Original question retrieved from Google Cache:
I am trying to program a function into matlab but I am struggling to get started. I want to program it as a function and not as part of a script so that I may use it later on when I need it.
Basicaly, there will be n number of terms, and x and y are arrays that will change in size depending on how have set them up.
Rena Berman
Rena Berman el 6 de Mayo de 2021
(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 20 de Abr. de 2021
c = @(x,y) sum(sqrt((a-x).^2 + (b-y).^2))

Jan
Jan el 20 de Abr. de 2021
function c = YourSum(x, y, a, b)
c = sum(sqrt((a - x).^2 + (b - y).^2));
end

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by