recalculation with different rsult respect to previous one

2 Ansichten (letzte 30 Tage)
Saeid Pourmasoud
Saeid Pourmasoud am 21 Mär. 2023
Kommentiert: Saeid Pourmasoud am 25 Mär. 2023
Dear all.
Can any one help me about my problem in Mathlab code as following? I have obtained a result and drawn a plot . But, the problem is once I want to do, once again, THE SAME calculations with THE SAME INPUT PARAMETERS, I get DIFFERENT plot. It is very strange and confusing.

Antworten (1)

Walter Roberson
Walter Roberson am 21 Mär. 2023
This can happen for a couple of different reasons:
  • if the calculations involve random numbers. The random number use might not always be obvious: for example although it is not immediately obvious, kmeans() by default uses random initialization of cluster locations;
  • if you have some kind of accumulation of results and your code forgets to explicitly initialize the variables;
  • if your code relies upon expanding an array and your code does not remember to initialize the array. For example if you have code like A(end+1) = calculation; B = sum(A); then if the code does not remember to clear / truncate the array A then the second time you would be calculating based on results stored the first time through.
  5 Kommentare
Walter Roberson
Walter Roberson am 24 Mär. 2023
Bearbeitet: Walter Roberson am 24 Mär. 2023
You did not send thue() or fib_bin() or rt_coefficient_te() or rt_coefficient_tm()
Saying
in one category you can put A=0; alpha=1.08, beta=1.86
in another category you can put A=0.2, alpha=1.01, beta=1.95
does not give me enough information about how the code should be run, or what should be plotted, or what I should be looking for when you say the second run returns different results.
Saeid Pourmasoud
Saeid Pourmasoud am 25 Mär. 2023
Thank you so much. I solved the problem myself.
With the best wishes

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by