Different results when passing the same value in a function.
Afficher commentaires plus anciens
Hi guys,
I have never had this problem in MATLAB before since I assumed variable definition is not necessarily needed unlike C, C++, Fortran, etc. I am running the following code:
------------------------------------------------------------------------------------------------
clear all
format long
start_delta = 0.015;
end_delta = 0.05;
delta_step = 0.0001;
i_MAX = ceil((end_delta - start_delta)/delta_step);
axmine = double(zeros(i_MAX, 64));
aymine = double(zeros(i_MAX, 64));
azmine = double(zeros(i_MAX, 64));
delta_array = double(zeros(i_MAX, 1));
delta_array(1) = start_delta;
[axmine(1,:), aymine(1,:), azmine(1,:)] = lorenzmine(0.015);
[axmineother, aymineother, azmineother] = lorenzmine(delta_array(1));
delta_array(2) = start_delta + delta_step;
[axmine(2,:), aymine(2,:), azmine(2,:)] = lorenzmine(0.0151);
[axmineother2, aymineother2, azmineother2] = lorenzmine(delta_array(2));
------------------------------------------------------------------------------------------------
I am passing the value 0.015, 0.0151, 0.0152, etc as a parameter using the array delta_array and also as a value in the function lorenzmine(). The output from the function lorenzmine() axmine(1,:), aymine(1,:) and azmine(1,:) matches the array axmineother, aymineother and azmineother whether I pass delta_array(1) or 0.015. I would think that would be the case with 0.0151 as well, but to my surprise the array axmine(2,:) DOESNT match axmineother2, aymine(2,:) DOESNT MATCH aymineother2 and so on. It seems like passing 0.0151 as a value and as a parameter gives different results. Any input into this would be appreciated. Thanks.
1 commentaire
Star Strider
le 29 Juin 2014
lorenzmine?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Configuring Code Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!