Matlab App Designer Plot

조회 수: 15 (최근 30일)
Olivia Wells
Olivia Wells 2018년 11월 18일
편집: Cris LaPierre 2020년 12월 9일
I can run the GUI i created but i am having difficulties when i press the calculate button. Everything works fine and the graph appears however an extra empty figure window is also appearing. I am new to matlab so i am unsure how to resolve the problem. Also I would like the x grid to be visible upon running the GUI (the inital graph should have the x grid on so it resembles strips of wood in my case) but i cannot figure out how to do this. Once i run my GUI and press calculate the grid lines show up but they dont upon initally opening running the GUI
any help is appreciated! thank you

채택된 답변

Cris LaPierre
Cris LaPierre 2018년 11월 18일
Without seeing your code, we can only guess. The most likely reason is you did not tell the plot command which axes to plot to. Include the target axes in the plot command:
plot(app.UIAxes,X,Y)
For the grid lines - in the design view in appDesigner, select your axes and then in the Axes Properties (on the right), expand GRIDS and place a check box in XGrid.
xGrid.png
  댓글 수: 2
Olivia Wells
Olivia Wells 2018년 11월 19일
Here is my code below, I added your suggestion and the other figure pops up but it still graphs in the GUI properly. Also, I have the X Grid box checked already and it wont show up in the design view.
fig = app.UIFigure;
ax = app.UIAxes;
line (app.UIAxes,[x1(i,1), x2(i,1)], [y1(i,1), y2(i,1)]);
axis([0 8 -1 8])
hold on;
Screen Shot 2018-11-18 at 4.57.46 PM.png
Cris LaPierre
Cris LaPierre 2018년 11월 19일
편집: Cris LaPierre 2020년 12월 9일
Are you using appdesigner to build your app or doing it programatically? It looks like appdesigner, so you do not need the following code
fig = app.UIFigure;
This is likely what is causing a second window to appear.
Also, you really don't need
ax = app.UIAxes;
Instead drag an axes component onto your canvas in the design view. Take note of the name (you can change it to be anything you want). This name is what you will use when specifying your target axes.
Also note that you must include a target axes for the axis and hold commands
axis(app.UIAxes,[0 8 -1 8]);
hold(app.UIAxes,'on')

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

추가 답변 (1개)

Angel Lozada
Angel Lozada 2020년 5월 15일
Hello.
I am trying to plot functions using Matlab AppDesigner.
It is possible to find my inquiry (better explained) in the attached file.
Regards.
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2020년 5월 15일
You should start a separate question for this request. Creating the plot is not the actual problem. It is converting a text input to a mathematical equation.
Angel Lozada
Angel Lozada 2020년 5월 15일
Dear Cris.
I will follow your suggestion.
Regards.

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

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by