Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why I get different outcomes from iteration as part of a big function and iteration as main part of a small function

1 回表示 (過去 30 日間)
TingTing
TingTing 2014 年 4 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi,
I'm really bothered by this issue and will appreciate help very much.
I have a while loop which has only 7 lines and involve nothing more than plus, minus, exp, logncdf and normcdf. I use a step of 0.000001 to adjust my input variable until it gives output closer to the truth I believe in. This is currently part of a sub-function in a big function However, it will never finish the loop. While if I take the sub-function out, give its input vairables the values which should be when the big funtion runs til this step, this separate function will solve quickly. Since I do need this to be part of the big function, I am kind of iritated by this. Do you have any explanation? does it have something to do with the capacity of Matlab or... ? Everything is the same, the input values were set to be the same and it runs well as a separate function, but not so when this separate function is sub-function of a big function which carries many variable... :(
Thanks in advance!
  2 件のコメント
Sara
Sara 2014 年 4 月 25 日
Post the code, so we can see exactly what you are doing, e.g., how do you increment variables.
TingTing
TingTing 2014 年 5 月 14 日
Hi Sara, thank you for your response. Mathwork doesn't send me reminder when a commented is given, so I thought nobody responded...
In the days I thought so, I checked my program again and found what I described was not really true. When I said "if I take the sub-function out, give its input vairables the values which should be when the big funtion runs til this step, this separate function will solve quickly.", I manually wrote down and keyed in the values I saw on the screen. However, I skipped the digits after the decimal, so the values were slightly changed and this set of values CAN ran through the sub-function when it is taken out alone. Actually, it can also run through the sub-function when it is in the big function. However, if I use the real values (taken from the system by save xxx.mat), this set of value won't run through either the sub-function alone or the sub-function in the main function. So its not an issue with the capacity of matlab. It's my own sub-function's lack of robustness.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by