【物理应用】基于matlab GUI家庭室内温湿度控制【含Matlab源码 326期】
【摘要】
一、获取代码方式
获取代码方式1: 完整代码已上传我的资源:【物理应用】基于matlab GUI家庭室内温湿度控制【含Matlab源码 326期】
获取代码方式2: 通过订阅紫极神光博客付费专栏,凭支...
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【物理应用】基于matlab GUI家庭室内温湿度控制【含Matlab源码 326期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
function varargout = HomeMonitoringSystem(varargin)
% HOMEMONITORINGSYSTEM MATLAB code for HomeMonitoringSystem.fig
% HOMEMONITORINGSYSTEM, by itself, creates a new HOMEMONITORINGSYSTEM or raises the existing
% singleton*.
%
% H = HOMEMONITORINGSYSTEM returns the handle to a new HOMEMONITORINGSYSTEM or the handle to
% the existing singleton*.
%
% HOMEMONITORINGSYSTEM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HOMEMONITORINGSYSTEM.M with the given input arguments.
%
% HOMEMONITORINGSYSTEM('Property','Value',...) creates a new HOMEMONITORINGSYSTEM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before HomeMonitoringSystem_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to HomeMonitoringSystem_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help HomeMonitoringSystem
% Last Modified by GUIDE v2.5 09-Apr-2013 21:36:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @HomeMonitoringSystem_OpeningFcn, ...
'gui_OutputFcn', @HomeMonitoringSystem_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before HomeMonitoringSystem is made visible.
function HomeMonitoringSystem_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to HomeMonitoringSystem (see VARARGIN)
% Choose default command line output for HomeMonitoringSystem
handles.output = hObject;
web -browser http://www.ilovematlab.cn/thread-201914-1-1.html
% Update handles structure
global smtp_server_status camera_working temp_humd_working
smtp_server_status=0; %邮件系统是否工作 Email System Status
camera_working=0;%相机是否能工作 Camera can work or not?
temp_humd_working=0; %温度计、湿度计是否在工作 temperature/humidity sensor works or not?
handles.live_view=0; %系统是否在监视
handles.receiver1='';%接受人邮件地址
handles.receiver2='';
handles.receiver3='';
%默认为中文界面 By Default, load the Chinese GUI
handles.my_gui_msg_struct = msg_cn();
guidata(hObject, handles);
%删除所有现有的计时器
%Delete all timers in the system
try
out = timerfind;
stop(out);
delete(out);
catch exception
end
% UIWAIT makes HomeMonitoringSystem wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = HomeMonitoringSystem_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in PB_real_time_video.
function PB_real_time_video_Callback(hObject, eventdata, handles)
% hObject handle to PB_real_time_video (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% UD_capture_image(hObject,handles);
%
% TM_video = timer('TimerFcn',{@UD_capture_image,hObject,handles}, 'Period', 0.5);
% start(TM_video);
%相机是否能正常工作,只有获取第一副图片以后,该状态才被改变
%The camera is working unless one image is captured
global camera_working
camera_working=0;
warning('off');
guidata(hObject, handles);
% 判断系统是否已经有定时器在运行,若是,则删除现有的定时器
% Determine if it is already running. Stop the timer is so.
try
out = timerfind('Tag', 'Continuous Capture');
stop(out);
delete(out);
catch exception
end
% 获得帧数
% Get the fps from GUI
try
video_fs=1/str2num(get(handles.TE_video_fs,'string'));
if str2num(get(handles.TE_video_fs,'string'))<0 | str2num(get(handles.TE_video_fs,'string'))>100
throw(exception);
end
catch exception
msgbox(handles.my_gui_msg_struct.live_view_wrong_fps);
return;
end
% 获取抓取图片的URL链接
% Get the URL for image capture
handles.image_url=get(handles.TE_image_url,'string');
% 定义一个全局变量,用于储存网络摄像头的用户名和密码
% Define a global variable to store username and password
global global_url_pwd;
global_url_pwd=base64_encode(get(handles.TE_url_pwd,'string'));
% 创建一个计时器,回调函数为UD_capture_image
% Create a timer with callback UD_capture_image
handles.UD_continuous_capture_timer = timer('Tag','Continuous Capture','period',video_fs);
set(handles.UD_continuous_capture_timer,'ExecutionMode','fixedrate','StartDelay',0.5);
set(handles.UD_continuous_capture_timer,'TimerFcn',{@UD_capture_image,hObject,handles});
start(handles.UD_continuous_capture_timer);
guidata(hObject, handles);
function UD_capture_image(~, ~, hObject,handles)
% 读取图片
% Read an image
try
handles.raw_image=imread_auth(handles.image_url);
catch exception
msgbox(handles.my_gui_msg_struct.live_view_wrong_URL_username_password);
try
out = timerfind('Tag', 'Continuous Capture')
stop(out);
delete(out);
catch exception2
end
return;
end
% 显示图片,更新状态
% show the image, Update System Status
handles.live_view=1;
global camera_working
camera_working=1;
guidata(hObject, handles);
imshow(handles.raw_image,'Parent',handles.AX_video);
% --- Executes on button press in PB_stop_real_time_video.
function PB_stop_real_time_video_Callback(hObject, eventdata, handles)
% hObject handle to PB_stop_real_time_video (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
out = timerfind('Tag', 'Continuous Capture');
stop(out);
delete(out);
catch exception
end
handles.live_view=0;
guidata(hObject, handles);
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
% delete(hObject);
% Delte all timers
try
out = timerfind;
stop(out);
delete(out);
catch exception
end
web -browser http://www.ilovematlab.cn/thread-201914-1-1.html
delete(hObject);
function TE_video_fs_Callback(hObject, eventdata, handles)
% hObject handle to TE_video_fs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of TE_video_fs as text
% str2double(get(hObject,'String')) returns contents of TE_video_fs as a double
% --- Executes during object creation, after setting all properties.
function TE_video_fs_CreateFcn(hObject, eventdata, handles)
% hObject handle to TE_video_fs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in CB_monday.
function CB_monday_Callback(hObject, eventdata, handles)
% hObject handle to CB_monday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_monday
% --- Executes on button press in CB_tuesday.
function CB_tuesday_Callback(hObject, eventdata, handles)
% hObject handle to CB_tuesday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_tuesday
% --- Executes on button press in CB_wednesday.
function CB_wednesday_Callback(hObject, eventdata, handles)
% hObject handle to CB_wednesday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_wednesday
% --- Executes on button press in CB_thursday.
function CB_thursday_Callback(hObject, eventdata, handles)
% hObject handle to CB_thursday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_thursday
% --- Executes on button press in CB_friday.
function CB_friday_Callback(hObject, eventdata, handles)
% hObject handle to CB_friday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_friday
% --- Executes on button press in CB_saturday.
function CB_saturday_Callback(hObject, eventdata, handles)
% hObject handle to CB_saturday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_saturday
% --- Executes on button press in CB_sunday.
function CB_sunday_Callback(hObject, eventdata, handles)
% hObject handle to CB_sunday (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of CB_sunday
% --- Executes on selection change in PM_hours.
function PM_hours_Callback(hObject, eventdata, handles)
% hObject handle to PM_hours (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns PM_hours contents as cell array
% contents{get(hObject,'Value')} returns selected item from PM_hours
% --- Executes during object creation, after setting all properties.
function PM_hours_CreateFcn(hObject, eventdata, handles)
% hObject handle to PM_hours (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/113851070
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)