Borrar filtros
Borrar filtros

Saving vector result from each loop if solution is correct.

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by