Variable not updating with each iteration

17 ビュー (過去 30 日間)
zephyr21
zephyr21 2016 年 6 月 19 日
コメント済み: zephyr21 2016 年 6 月 19 日
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 件のコメント
zephyr21
zephyr21 2016 年 6 月 19 日
Ok thank you. I have attached the files. "properties" basically just provides "singlephase2" with information it needs to solve equations and "gmresSolver" is just a function needed to solve the matrix. The problem is in "singlephase2". The [x] matrix is formed at the end where I believe the problem occurs when it solves for [x] and continually gives me the same value of 7750 no matter what I change "t" to. Thanks for looking.
Stephen23
Stephen23 2016 年 6 月 19 日
編集済み: Stephen23 2016 年 6 月 19 日
@zephyr21: ...and learn to use the debugging tools. They also work when there is no error, i.e. when you are writing, testing, and checking your code. No error needed.

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 6 月 19 日
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.
  1 件のコメント
zephyr21
zephyr21 2016 年 6 月 19 日
Thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by