Cannot get output printed for every iteration of while loop.
Mostrar comentarios más antiguos
I've been assigned a problem where I'm trying to print out a vector for each iteration of this while loop. Unfortunately it seems like it will only print out the vector when n = 13, when I need printed vectors from n=2 to 13.
n=2;
inc=1;
while n < 100
H_mat=hilb(n);
x_vec=rand(n,1);
b_vec=H_mat*x_vec;
x_approx=H_mat\b_vec;
fprintf('Approximate x value: \n');
disp(x_approx);
if (n > 13)
break;
end
n = n + 1; % Increment n for the next iteration
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Hilbert and Walsh-Hadamard Transforms en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!