Displaying non existant array elements
Afficher commentaires plus anciens
Why am I getting repeating numbers for the array x as an output for the following piece of script?
x=1:0.5:5;
for i=1:length(x);
y(i)=x(i)^2;
end
fprintf(' x y\n')
Results=[x;y];
fprintf('%10.0f %38.16f\n', Results);
1 commentaire
Stephen23
le 8 Mar 2025
“Why am I getting repeating numbers for the array x as an output for the following piece of script?”
You are not getting the same values repeating in x. You just confused how values are displayed with the values stored in memory. Try printing the values of x with e.g. two decimal places. Then tell us what you see.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!