使用Matlab App Designer设计一个 电子日志app
由于坚持记录已经有一段时间,决定DIY一款app用于记录,主要包含以下功能:记录每日时间分配并查看;记录阅读书籍并查看;记录练习歌曲并查看;记录体重并查看;记录notes并查看;添加类别并记录倒计时功能(目前还不完善)。。。
安装程序下载
百度网盘下载链接:https://pan.baidu.com/s/1uCuPcgs2HQ3crx3LLb0kuw
提取码:j1m0
设计页面如下:
具体代码。。。
classdef app_record < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
UIAxes2 matlab.ui.control.UIAxes
NotesTextArea matlab.ui.control.TextArea
DateSaveDatePicker matlab.ui.control.DatePicker
kgEditFieldLabel matlab.ui.control.Label
kgEditField matlab.ui.control.NumericEditField
SaveButton matlab.ui.control.Button
DateCheckDatePicker matlab.ui.control.DatePicker
SleepEditFieldLabel matlab.ui.control.Label
SleepEditField matlab.ui.control.NumericEditField
HobbyEditFieldLabel matlab.ui.control.Label
HobbyEditField matlab.ui.control.NumericEditField
ResearchEditFieldLabel matlab.ui.control.Label
ResearchEditField matlab.ui.control.NumericEditField
SocialEditFieldLabel matlab.ui.control.Label
SocialEditField matlab.ui.control.NumericEditField
TimehLabel matlab.ui.control.Label
TotalLabel matlab.ui.control.Label
DropDown matlab.ui.control.DropDown
BookEditFieldLabel matlab.ui.control.Label
BookEditField matlab.ui.control.EditField
SongEditFieldLabel matlab.ui.control.Label
SongEditField matlab.ui.control.EditField
Label_2 matlab.ui.control.Label
Label_3 matlab.ui.control.Label
Label_4 matlab.ui.control.Label
HourSpinnerLabel matlab.ui.control.Label
HourSpinner matlab.ui.control.Spinner
AddButton matlab.ui.control.Button
UITable matlab.ui.control.Table
TextArea matlab.ui.control.TextArea
UITable2 matlab.ui.control.Table
UITable3 matlab.ui.control.Table
EditField matlab.ui.control.EditField
end
properties (Access = public)
val = load("sim.mat",'notes'); % Description
val2 = load('sim.mat','t_consumption');
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
flag = 0;
if length(app.NotesTextArea.Value) > 1
note_combine = strjoin(app.NotesTextArea.Value(1:end));
n = cellstr(note_combine);
elseif length(app.NotesTextArea.Value) == 1
n = app.NotesTextArea.Value;
end
if isnat(app.DateSaveDatePicker.Value) == 1
app.DateSaveDatePicker.Value = datetime('today');
end
if isempty(app.BookEditField.Value) == 1
book = ' ';
else
book = app.BookEditField.Value;
end
if isempty(app.SongEditField.Value) == 1
song = ' ';
else
song = app.SongEditField.Value;
end
for i = 1:length(app.val.notes.Time)
if app.DateSaveDatePicker.Value == app.val.notes.Time(i)
flag = i;
end
end
if flag > 0
selection = uiconfirm(app.UIFigure,'The record already exists, confirm to overwrite?','Comfirm Overwrite');
if length(selection) == 2
app.val.notes{flag,1} = app.kgEditField.Value;
app.val.notes{flag,2} = app.SleepEditField.Value;
app.val.notes{flag,3} = app.HobbyEditField.Value;