필터 지우기
필터 지우기

How can I fix this error and what does mean by should return 1 or two arguments help pls

조회 수: 2 (최근 30일)
% Check userfun
userFG = checkFun(userfun,'SNOPT','userfun');
gotDeriv = 0;
try
[F,G] = userFG(x);
gotDeriv = 1;
catch
try
F = userFG(x);
gotDeriv = 0;
catch
error('SNOPT:InputArgs','userfun should return 1 or 2 arguments');
end
end
Error
Error using snopt (line 318)
userfun should return 1 or 2 arguments
Error in Untitled2 (line 173)
[x, f, inform, xmul, fmul] = snopt(xg, xlwr, xupr, xmul, xstate, ...

채택된 답변

Jan
Jan 2021년 9월 6일
Which userfcn do you provide? You have to insert changes there, so please post the code of your userfcn.
It should start with
function [output1, output2] = theNameOfYourFcn()
% ^^^^^^^ ^^^^^^^
end

추가 답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 9월 6일
userFG shall return one or two arguments. You can see that the code tries to call userFG and retrieves two returns. If this call throws an exception, then it tries to call userFG and retrieve one retuen. If this also throws exception, then it errors out. So it expects one or two returns.
  댓글 수: 4
Mudrik Ahmed
Mudrik Ahmed 2021년 9월 7일
Thanks, I managed to set path for SNOPT and everything just seems sorted apart from other minor errors

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

카테고리

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

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by