Filter löschen
Filter löschen

Saving vector result from each loop if solution is correct.

2 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by