📄 g_homework.m
字号:
% G_HOMEWORK: Homework Builder GUI module
%
% Usage: g_homework
%
% Version: 1.0
%
% Description:
% This graphical user interface module is an instructor's
% supplement to the text "Fundamentals of Digital Signal
% Processing using MATLAB" by R. J. Schilling and S. L
% Harris, Pacific Grove, CA: Brooks/Cole, 2005. It is
% designed to facilitate the creation of homework
% assignments using end-of-chapter problems. Both the
% homework assignemnt and a PDF file solution can be
% generated with this "Homework Builder" GUI module.
%
% Create assignment pushbuttons:
%
% Course number
% Homework number
% Due date
% Section numbers
%
% Select problems pushbuttons:
%
% Select problems
% Delete problems
% Insert problems
% Generate ranom problems
% Menu bar:
% Load option
% Save option
% Solutions option
% Print option
% Help option
% Programming notes:
% 1) Fix Solution path code to work with any drive later!
% Check MATLAB Version
if (f_oldmat)
return
end
% Initialize
clc
clear all
course_number = {'EE301'}; % course number
homework_number = '1'; % homework assignment number
due_date = '10/1/2005'; % homework due date
np = 5; % number of problems in homework assignment
sec = {'1.5','2.10'}; % range of textbook sections for homework assignment
show_sec = 1; % show section for each homework problem
white = [1 1 1];
pdf_file = '';
space = ' ';
quote = '''';
% Add solutions directory to path
[cd_found,solution_ps,solution_pdf] = f_checkcd;
% Check preferences
try
course_number = getpref ('FDSP_preferences','course_number');
catch
course_number = {'EE301'};
end
% Create cell array of problems
[problems,secs,nums] = f_problems;
% Strings
userinput = 'homework1';
cprobstr = '[cprobs,clist] = f_probrange (sec,problems); ';
rprobstr = '[prob,np] = f_randprob (np,sec,problems,1,nums); ';
plotstr = 'hv = f_plothome (han,course_number,homework_number,due_date,sec,problems,prob,show_sec,fsize); ';
% Create figure window with tiled axes
[hf_1,han,pos,colors,ht,fsize] = f_guihome;
delfcn = ['warning off, rmpath(solution_ps); rmpath(solution_pdf), warning on'];
set (hf_1,'DeleteFcn',delfcn)
% Load menu option
cback_load = [plotstr ...
'set(ht_course,''String'',course_number); '...
'set(ht_homework,''String'',homework_number); '...
'set(ht_date,''String'',due_date); '...
'set(ht_sec,''String'',[sec{1} '' to '' sec{2}]); '];
hm_load = f_loadmenu (userinput,'Load',cback_load);
% Save menu option
savestr = '''course_number'',''homework_number'',''due_date'',''sec'',''prob'',''show_sec''';
hm_save = f_savemenu (userinput,savestr,'Save');
% View solutions menu option
hm_3 = uimenu (hf_1,'Label','Solutions');
olddir = pwd;
fdspdir = [matlabroot filesep 'toolbox' filesep 'fdsp' filesep 'fdsp'];
cd (fdspdir)
try
reader_path = getpref ('FDSP_preferences','reader_path');
reader_file = getpref ('FDSP_preferences','reader_file');
hm31 = uimenu (hm_3,'Label','Select assigned homework problem');
cback_solve = [
'problist = problems(prob,2); '...
'[s,v] = listdlg(''PromptString'','...
'''Select the homework assignment number.'','...
'''ListSize'',[150 300],'...
'''SelectionMode'',''single'','...
'''ListString'',problist);'...
'q = problems{prob(s),2}; '...
'pdf_file = which([''prob'' q(1) ''_'' q(3:end) ''.pdf'']); '...
'fprintf (''Initializing Adobe Acrobat Reader...\n''); '...
'work_dir = pwd; '...
sprintf('cd(''%s''); ',reader_path)...
'set(hf_1,''Visible'',''off''); '...
'eval( [''system('' quote reader_file space pdf_file quote '')''] ); '...
'set(hf_1,''Visible'',''on''); '...
'clc, cd(work_dir);'
];
set (hm31,'Callback',cback_solve)
hm32 = uimenu (hm_3,'Label','Select entire chapter');
cback_solvechap = [
'problist = problems(prob,2); '...
'[s,v] = listdlg(''PromptString'','...
'''Select chapter number.'','...
'''ListSize'',[150 300],'...
'''SelectionMode'',''single'','...
'''ListString'',nums(1:9)); '...
'pdf_file = sprintf(''problems_%d.pdf'',s); '...
'pdf_file = which(pdf_file); '...
'fprintf (''Initializing Adobe Acrobat Reader...\n''); '...
'work_dir = pwd; '...
sprintf('cd(''%s''); ',reader_path)...
'set(hf_1,''Visible'',''off''); '...
'eval( [''system('' quote reader_file space pdf_file quote '')''] ); '...
'set(hf_1,''Visible'',''on''); '...
'clc, cd(work_dir);'
];
set (hm32,'Callback',cback_solvechap)
catch
cback = ['helpwin (''f_regreader'')'];
hm_30 = uimenu (hm_3,'Label','Help','Callback',cback);
end
% Reader updates
cback = ['if f_regreader, '...
' close, g_homework, '...
'end'];
hm_32 = uimenu (hm_3,'Separator','on','Label','Register Acrobat Reader with FDSP','Callback',cback);
cback = ['web http://www.adobe.com/products/acrobat/readstep2.html;'];
hm_33 = uimenu (hm_3,'Label','Download Adobe Acrobat Reader','Callback',cback);
cd (olddir)
% Print menu option
cback_print1 = [
'for i = 1 : 2, '...
' set(han(i),''Visible'',''off''), '...
' set(ht(i),''Visible'',''off''), '...
'end, '...
'set(hc_course,''Visible'',''off''), '...
'set(hc_homework,''Visible'',''off''), '...
'set(hc_date,''Visible'',''off''), '...
'set(hc_sec,''Visible'',''off''), '...
'set(hc_showsec,''Visible'',''off''), '...
'set(ht_course,''Visible'',''off''), '...
'set(ht_homework,''Visible'',''off''), '...
'set(ht_date,''Visible'',''off''), '...
'set(ht_sec,''Visible'',''off''), '...
'set(hc_select,''Visible'',''off''), '...
'set(hc_delete,''Visible'',''off''), '...
'set(hc_insert,''Visible'',''off''), '...
'set(hc_random,''Visible'',''off''), '...
'set(han(3),''Position'',[.07 0 .86 1]), '...
'set(hv,''Visible'',''off''), '...
'print -v; '...
'set(han(3),''Position'',pos(3,:)), '...
'set(hv,''Visible'',''on''), '...
'for i = 1 : 2, '...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -