Syntax and code in function parameter for ~

조회 수: 2 (최근 30일)
Emma Humphrey
Emma Humphrey 2018년 9월 22일
댓글: Stephen23 2018년 9월 23일
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
Stephen23
Stephen23 2018년 9월 23일
These were both easy to find using [a major internet search engine]:
https://www.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html>

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2018년 9월 22일
편집: John D'Errico 2018년 9월 22일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by