Plotting in a GUI

조회 수: 9 (최근 30일)
Paul Rogers
Paul Rogers 2020년 11월 9일
댓글: Paul Rogers 2020년 11월 12일
Hi, I am new to GUI, I did my first program but now I am stuck in plotting the results.
I'd like to plot the results I get from the function I inserted.
I've prevviously run this on a simple Matlab file, and I'd like to plot:
y(:,1)
y(:,2)
versus time. So basically I used to write:
plot(time,phi)
or
plot(time,psi)
I put in attached the file I did. The problem is at line 494 where I commented
  댓글 수: 2
Rik
Rik 2020년 11월 9일
If you are new to GUIs, you should probably avoid GUIDE for anything that you work with for more than an hour or so.
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread.
The end problem you/Cris encountered is because GUIDE is ancient and uses the old convention of not closing functions with end. In R13 (a release that is old enough to drink in many countries) you even get a warning if you do close functions with end. With the introduction of nested functions in R14 there was a specific need to match functions with an end to be able to find out if a function was a nested function or an outer function. The importance of closing functions with end has increased even more with the possibility of having functions inside script files (introduced in R2016b). It wouldn't surprise me if at some point in the future the closing keyword will be mandatory. That will be the day that finally all GUIDE-generated GUIs will break.
Cris LaPierre
Cris LaPierre 2020년 11월 10일
I was going to recommend app designer, but saw the OP is using R2012b. If updating is a possibility, I strongly recommend it. If not, you an still definitely get this working in guide.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 11월 9일
You will need to specify the axes handles as part of the plot command. You command should look something like this (untested):
plot(handles.axes1,time,phi)
  댓글 수: 14
Cris LaPierre
Cris LaPierre 2020년 11월 10일
편집: Cris LaPierre 2020년 11월 10일
1. With your grid commands, you have to tell it which axes to apply the command to. Try something like this.
plot(handles.axes4,t,y(:,1))
grid(handles.axes4,'on')
grid(handles.axes4,'minor')
...
2. Static text boxes are, well, static. There is no callback because they cannot be changed. Use an Edit Text component in order to get a callback.
3. No. You have to manually delete the code. I suggest before deleting, rt clicking and going to the callback and create functions first, deleting them, then deleting the component.
Paul Rogers
Paul Rogers 2020년 11월 12일
thanks Cris LaPierre,
sorry for asking a lot but I couldn't find anything online for the GUI.
I post a snapshoot of the semi-final model (I'd like to make some adjstment in the next weeks)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Buffers, Switches, and Counters에 대해 자세히 알아보기

제품


릴리스

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by