Variable not updating with each iteration
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
zephyr21
am 19 Jun. 2016
Kommentiert: zephyr21
am 19 Jun. 2016
I have many different equations with variables and coefficients running through a for loop and at the end, are sorted into [A] [b] and [x] matrices which are used to perform matrix math to solve for unknown x's before the loop starts over. [A] consists of the coefficients, [b] consists of numbers changing with the increase of each time step, and [x] consists of variables that are supposed to be updating. The problem is that the [x] variables aren't updating, it just gives me the original x's each time. What am I doing wrong? I would post the code here but it is pretty lengthy.
8 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 19 Jun. 2016
zephyr21 - the function signature for gmresSolver is
function [ x, error_norm, iter, flag ] = gmresSolver ( A, x, b, M, restart, max_it, tol, n )
which returns four output parameters including x. Your code calls this function (from within SinglePhase2) as
gmresSolver(A,x,b,.0001,10,I*J,0.0000001,K);
and so the output from this function is being ignored. I suspect that you want to do something more like
[x,error_norm,iter,flag] = gmresSolver(A,x,b,.0001,10,I*J,0.0000001,K);
which will then update your x.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!