Draw a circle on matlab app designer?

조회 수: 34 (최근 30일)
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras . 2021년 1월 17일
댓글: ErikJon Pérez Mardaras . 2021년 1월 17일
I am making an app on Matlab app designer which consist on the following as you can see below: A graph panel and a Button, which when clicked, a circle that I have defined in the code is drawn. The issue here is that I have made two different codes that work perfectly in the command window but in app designer only works one, while the other one does not.
One of those both codes I have designed is the following one. Here I define the code of the circle I would like to draw when I click the button
As you can see, It is drawn perfectly
But this is the other code (much more easier to me) that doesn't draw well the circle
This is what it draws:
I would like to know how can I make the second code to draw the circle perfectly. Why doesn't it draw the circle? I don't understand why both of them work perfectly on the command window and thet don't on matlab app.designer.
Thank you very much!

채택된 답변

Mischa Kim
Mischa Kim 2021년 1월 17일
Hi ErikJon, if the plot input is a matrix (e.g. your circ) "...the plot function plots the columns of the matrix (circ) versus their row number. The x-axis scale ranges from 1 to the number of rows in the matrix." So this is the designed behavior of the plot command for matrices. See the documentation here for plot(Y) for more info.
  댓글 수: 3
Mischa Kim
Mischa Kim 2021년 1월 17일
Different behavior between running from the command window and as an app would indeed be confusing. What happens if you run the following from the command window?
r = 4;
caca = 2*pi;
ang = linspace(0,caca);
xp = r*cos(ang);
yp = r*sin(ang);
circ = [xp;yp];
For me this creates the same two plots that you are showing in your question, as it should.
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras 2021년 1월 17일
Sorry! That's true. My fault
Thanks a lot for your reply!

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

추가 답변 (0개)


Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by