CS211 Lab Policy:
Instructions:
For this lab you will modify your GUI program from Lab 30 to add standard menus and a context menu to the plotting program. Since it is complicated to rename GUI program file names, please start your assignment with these files: Lab31.fig, Lab31.m. (use right-click, save target as...)
[FileName DirectoryName] = uiputfile('*.mat'); if FileName ~= 0 FileName = [DirectoryName FileName]; Coefficients = [ get(handles.Slider_a, 'Value') ... get(handles.Slider_b, 'Value')]; save(FileName, 'Coefficients'); end
[FileName DirectoryName] = uigetfile('*.mat'); if FileName ~= 0 FileName = [DirectoryName FileName]; load(FileName); set(handles.Slider_a, 'Value', Coefficients(1)); set(handles.Slider_b, 'Value', Coefficients(2)); Update_plot(handles); end
close(handles.figure1);
set(handles.Slider_a, 'Value', pi); set(handles.Slider_b, 'Value', 0.0); Update_plot(handles);
set(handles.Line_width_menu, 'UserData', 1); Lines = get(handles.Plot_axes, 'children'); set(Lines(1), 'LineWidth', 1);
set(handles.Line_width_menu, 'UserData', 3); Lines = get(handles.Plot_axes, 'children'); set(Lines(1), 'LineWidth', 3);
set(handles.Line_width_menu, 'UserData', 8); Lines = get(handles.Plot_axes, 'children'); set(Lines(1), 'LineWidth', 8);
A = get(handles.Slider_a, 'Value'); B = get(handles.Slider_b, 'Value'); X = -10:0.1:10; Line_handle = plot(handles.Plot_axes, X, cos(X+A) + sin(B*X) ); set(handles.Plot_axes, 'YLim', [-2 2]); Line_width = get(handles.Line_width_menu, 'UserData'); set(Line_handle, 'LineWidth', Line_width); set(handles.Title_text, 'String', ... ['cos(x+' num2str(A) ') + sin(' num2str(B) 'x)'] ); set(Line_handle, 'UIContextMenu', handles.Line_width_menu);
- Add the following line to the Lab31_openingFcn() function (before the line Update_plot(handles))
set(handles.Line_width_menu, 'UserData', 1);
Spend your remaining time working on the review for GR 2.
Turn-in:
Submit your Lab31.m and Lab31.fig files.