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

José-Luis
José-Luis 2014년 5월 14일
What have you tried so far?
Walter Roberson
Walter Roberson 2014년 5월 14일
spy() ?
zy
zy 2014년 5월 14일
I am new to matlab, so honestly speaking, I don't have much idea on how to do it.

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2014년 5월 14일

0 개 추천

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

zy
zy 2014년 5월 14일
It is really great help, I did some experiments and now I think I can get what I need now.
Thank you so much!
zy
zy 2014년 5월 14일
But I have one more question, what is the default unit for the distance between every two dots, and the default unit of the size for the dot? Because I need to know the physical distance between dots after I print the dot array in a piece of paper.
Star Strider
Star Strider 2014년 5월 14일
That probably depends on how you define them, and the size paper you use. See the documentation on Figure Properties. The PaperSize and related options may provide the information you need.
I haven’t done much with the actual units because that has rarely arisen in the applications I’ve encountered. It may require physical measurement and scaling in your code. It would be most efficient for you to export them as PDF files and measure them on your monitor in a PDF viewer (to save trees,important to me), and print them as necessary to verify your measurements. (My favourite PDF application suite, PDF X-Change, has measurement capabilities.)
zy
zy 2014년 5월 14일
Thanks a lot, I learned a lot from you, I really appreciate your help and guidance.
Star Strider
Star Strider 2014년 5월 14일
My pleasure!
zy
zy 2014년 7월 1일
Is there any way that I can set the length unit of the axes?
For example, can I set the length unit of both the x axis and y axis into 'cm' such that the axes on printed paper will be exact the length in cm I input in the code ?
Thank you.
Star Strider
Star Strider 2014년 7월 1일
That turns out to be very much a non-trivial problem. You will likely need to experiment a bit to get the result you want. See the documentation for print, and in Figure Properties, PaperPositionMode and its friends
zy
zy 2014년 7월 1일
Thank you for your suggestion.
Star Strider
Star Strider 2014년 7월 1일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

zy
2014년 5월 14일

댓글:

2014년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by