Cannot get output printed for every iteration of while loop.
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Hilbert and Walsh-Hadamard Transforms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!