I want to create a 2D scatter plot with loops

5 views (last 30 days)
Josh Kling
Josh Kling on 10 May 2022
Answered: KSSV on 10 May 2022
I want to display discrete values using a scatter plot graph covering 40 columns and 50 rows using a loop(s). (Domain 0<=x<=40) (Range 0<=y<=50.
Ive only managed to achieve 1 row but cannot manage to make more rows. How do i loop for the other 49 rows? (if that is even the best approach to this question).
y = linspace(0,i);
x = 0;
for i = 0:1:50
y = i
end
scatter(0:40,y, 'mo')

Answers (1)

KSSV
KSSV on 10 May 2022
[X,Y] = meshgrid(0:40,0:50) ;
scatter(X(:),Y(:),[],Y(:))
scatter(X(:),Y(:),[],X(:))

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!