필터 지우기
필터 지우기

Saving vector result from each loop if solution is correct.

조회 수: 2 (최근 30일)
Deokjae Jeong
Deokjae Jeong 2021년 10월 31일
댓글: Star Strider 2021년 10월 31일
Let's say DMP.m uses fsolve and output a solution vector, named xx. It can be `Equation solved', 'No solution found', or 'Equation solved but inaccuracy possible.'
I want to store the vector if it tells `Equation solved'.
So for example, my code is
for r=1:10
DMP
if exitflag==1
xxx(r,:)=xx
end
end
Unrecognized function or variable 'r'.
But Matlab gives me the error message: Unrecognized function or variable 'r'.
Could you help me the coding?

채택된 답변

Star Strider
Star Strider 2021년 10월 31일
Use the exitflag output from fsolve to determine whether a solution was found.
.
  댓글 수: 14
Deokjae Jeong
Deokjae Jeong 2021년 10월 31일
Oh.... It works. I am so thankful to you. I learned a lot.
Star Strider
Star Strider 2021년 10월 31일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by