Syntax and code in function parameter for ~

1 visualización (últimos 30 días)
Emma Humphrey
Emma Humphrey el 22 de Sept. de 2018
Comentada: Stephen23 el 23 de Sept. de 2018
Hello, I am new to Matlab and trying to understand the notation for the following code.
A function is created
function [sol, it_hist, ierr] = Newton(x,f,fdash,tol,parms)
When this function is being recalled in a driver, it uses the following notation. However, I am unsure which outputs of the function are being ignored.
[~, resids] = Newton(x,f,fd,tol,parms)
I assume the solution outputs 'sol' and 'it_hist' are the ones being ignored?
  1 comentario
Stephen23
Stephen23 el 23 de Sept. de 2018
These were both easy to find using [a major internet search engine]:
https://www.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html>

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 22 de Sept. de 2018
Editada: John D'Errico el 22 de Sept. de 2018
No. The function does NOT output sol and it_hist.
The ~ in position 1 tells MATLAB NOT to return the first argument. The second output is stuffed into the variable resids. (You called it that, not me.) So whatever was returned in it_hist is now in resids in the caller workspace.
The third argument is also dumped into the bit bucket, since you gave MALTAB no place to store it.

Más respuestas (0)

Categorías

Más información sobre Programming 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