Azzera filtri
Azzera filtri

Saving vector result from each loop if solution is correct.

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by