Displaying non existant array elements
Mostrar comentarios más antiguos
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 comentario
Stephen23
el 8 de Mzo. de 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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!