How to plot a dot array in Matlab

5 Ansichten (letzte 30 Tage)
zy
zy am 14 Mai 2014
Kommentiert: Star Strider am 1 Jul. 2014
I need to plot a array of black dots in matlab, it needs to be square array, all dots are uniformly spaced both horizontally and vertically. Also, I need to be able to adjust the size of each dot and to adjust the distance between every two dots in the code.
Thank you!
  3 Kommentare
Walter Roberson
Walter Roberson am 14 Mai 2014
spy() ?
zy
zy am 14 Mai 2014
I am new to matlab, so honestly speaking, I don't have much idea on how to do it.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 14 Mai 2014
This should get you started:
xy = [1:14]*200;
[X, Y] = meshgrid(xy);
xyo = xy([4 11]);
figure(1)
plot(X, Y, '.k')
% hold on
% plot(X(:,[4 11]), Y(:,[4 11]), 'ok')
% plot(X([4 11],:), Y([4 11],:), 'ok')
% plot(X([4 11],[4 11]), Y([4 11],[4 11]), 'sr')
% hold off
axis square
I originally wrote this for a slightly different problem. I left the other plot commands in but commented out in case you want to add circles or squares around the dots. You can adjust the size of the dots with the MarkerSize option. You can adjust the number of dots and the distance between the dots by changing the characteristics of the xy line:
xy = [1:14]*200;
Experiment with it until you get the result you want.
  9 Kommentare
zy
zy am 1 Jul. 2014
Thank you for your suggestion.
Star Strider
Star Strider am 1 Jul. 2014
My pleasure!
This has actually been the subject of several threads with different objectives, although if I remember correctly, most seemed to involve exporting them to LaTeX documents. You might want to search MATLAB Answers to see if one fits your particular requirements.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by