Creating a blank canvas in Matlab

조회 수: 10 (최근 30일)
Maryam NE
Maryam NE 2015년 2월 23일
댓글: Maryam NE 2015년 2월 23일
I am trying to replicate an experiment that has originally been done in Python, with Matlab. I would like to generate a bunch of circles of different sizes, colors and opacity and overlay them on top of each other inside a blank canvas. I would like to know if that is possible to be done in Matlab and what kind of commands I will need to use. For more details regarding the experiment please check the below link:
Thanks.

채택된 답변

Stephen23
Stephen23 2015년 2월 23일
편집: Stephen23 2015년 2월 23일
In MATLAB a "canvas" is called axes. Within axes can be displayed images or any data plotted. Empty axes are created simply using the axes command:
axes
You can then add/remove your circles inside these axes by using the patch command, or any other plotting command. You can access the current axes handle using gca .
Note that an axes does not exist by itself alone, but is always within a figure.
  댓글 수: 1
Maryam NE
Maryam NE 2015년 2월 23일
Thanks very much Stephen!

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

추가 답변 (2개)

Chris McComb
Chris McComb 2015년 2월 23일
I think that you should probably approach this using the patch command. This will allow you to specify circles with your desired parameters. The keyword alpha will allow you to control opacity.
% Size of circle
r = 5;
% Opacity
a = 0.1;
% Color
c = 'r';
theta = 0:0.1:2*pi;
x = r*cos(theta);
y = r*sin(theta);
patch(x, y, c, 'facealpha', a, 'edgecolor', c, 'edgealpha', a);
The additional argument of edgecolor and edgealpha make sure that the edge of the circle matches the interior.
  댓글 수: 1
Maryam NE
Maryam NE 2015년 2월 23일
Thanks Chris for your answer. But I still need to know if I will be able to create a blank canvas. I need to create let's say 100 random circles and overlay them inside a blank canvas. Is that possible? If so, how can I create that blank canvas, and how can I put the circles inside it?

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


Image Analyst
Image Analyst 2015년 2월 23일
I have a demo that does something pretty similar. See attached m-file below this image it creates.
  댓글 수: 1
Maryam NE
Maryam NE 2015년 2월 23일
This is very useful! Thanks! Pretty much what I'm looking for.

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

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by