- 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.
recalculation with different rsult respect to previous one
1 view (last 30 days)
Show older comments
Saeid Pourmasoud on 21 Mar 2023
Commented: Saeid Pourmasoud on 25 Mar 2023
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.
Walter Roberson on 21 Mar 2023
This can happen for a couple of different reasons:
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!