Create a static text box that displays a number, then adds one every time the GUI is opened.

1 次查看(过去 30 天)
I am trying to create a static text box that displays the value 'R0000001'. Then from that point on, every time the GUI opens or the "New" option from the tool bar is clicked the static text box displays the next value up.
For example when I open the GUI for the first time the static text box displays 'R0000001'. Then I choose "New" it will display 'R0000002'.After that I close it and reopen it again it will display "R0000003' ... and so on.
This GUI will be compiled to be a standalone application to be used by users that do not have MATLAB installed.
Is this possible?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-5-23
In your opening function
s=char(get(handles.text1,'string'));
n=num2str(str2num(s(2:end))+1);
s(end-numel(n)+1:end)=n
set(handles.text1,'string',s)
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-5-23
No, use a mat-file
In windows command, create a mat-file
s='R0000001'
save filename s
In your opening function
s=load('filename');
s=s.s
n=num2str(str2num(s(2:end))+1);
s(end-numel(n)+1:end)=n
set(handles.text1,'string',s)
save filename s

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming Utilities 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by