How can I have the numbers in one vector after a while loop?
Show older comments
Let say that I have a matrix A=[1 0 5 4; 2 0 5 4; 3 4 6 2]; and I am using the below code ( see my previews question Plot the numbers of a matrix as points (dots) in a plot) while any(A(:) > 0) [r,c] = find(A>0); X= randn; Y= randn; a=c+X b=r+Y A = A-1; end
it returns for a and b a =
1.4471
1.4471
1.4471
2.4471
3.4471
3.4471
3.4471
4.4471
4.4471
4.4471
b =
1.5364
2.5364
3.5364
3.5364
1.5364
2.5364
3.5364
1.5364
2.5364
3.5364
a =
0.6514
0.6514
1.6514
2.6514
2.6514
2.6514
3.6514
3.6514
3.6514
b =
3.1841
4.1841
4.1841
2.1841
3.1841
4.1841
2.1841
3.1841
4.1841
a =
1.2058
2.2058
3.2058
3.2058
3.2058
4.2058
4.2058
b =
3.1324
3.1324
1.1324
2.1324
3.1324
1.1324
2.1324
a =
1.4771
2.4771
2.4771
2.4771
3.4771
3.4771
b =
3.9398
1.9398
2.9398
3.9398
1.9398
2.9398
a =
1.6379
1.6379
1.6379
b =
0.2081
1.2081
2.2081
a =
3.6630
b =
3.5855
how can I have all the numbers of a and b in one vector respectively ?
1 Comment
Ang Vas seems to be referring to these questions:
@Ang Vas: Can you please format your code properly, to make it more readable.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!