Draw a circle on matlab app designer?
14 views (last 30 days)
Show older comments
ErikJon Pérez Mardaras
on 17 Jan 2021
Commented: ErikJon Pérez Mardaras
on 17 Jan 2021
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/490725/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/490730/image.png)
As you can see, It is drawn perfectly
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/490735/image.png)
But this is the other code (much more easier to me) that doesn't draw well the circle
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/490740/image.png)
This is what it draws:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/490745/image.png)
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!
0 Comments
Accepted Answer
Mischa Kim
on 17 Jan 2021
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 Comments
Mischa Kim
on 17 Jan 2021
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?
clear;
r = 4;
caca = 2*pi;
ang = linspace(0,caca);
xp = r*cos(ang);
yp = r*sin(ang);
circ = [xp;yp];
figure(1)
plot(xp,yp)
figure(2)
plot(circ)
For me this creates the same two plots that you are showing in your question, as it should.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!