{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Matlab_HW3_V3_Solutions_WebPost

# Matlab_HW3_V3_Solutions_WebPost - Eng101W07 Sec 100...

This preview shows pages 1–4. Sign up to view the full content.

Eng101W07 Sec 100 Homework 3 Due Friday, January 26, 2007, by 6 PM EST Upload to CTools Site Name: FILL-IN Lab GSI: FILL-IN Lab Section #: FILL-IN A. Preparatory work . With the shortened week, we’re short a lecture, so we’re going to do a little bit of Matlab housekeeping, a little bit of interpreting someone else’s code, some code generation of your own, and some work on the costs of doing business when all your real-valued numbers have to be expressed using a finite number of bits. For your outside reading, you should thoroughly read about the plot function using Matlab’s Help file. In preparation for lectures next week, I will be posting a reading on binary arithmetic and why, when we are computing, we need to take such things into consideration. For grins , you may want to check out some obscure references to MP3 and audio compression on the Web. At http://www.youtube.com/watch?v=YCLSkTEBj2k , you can hear a folk singer named Suzanne Vega interviewed in the online community, Second Life, concerning her role in the development of MP3. She then sing’s a capella her song “Tom’s Diner”. Everything she says is true, and actually, much more, as we’ll discuss in class on Monday.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
B. Answer the following questions. 1. [10 pts.] Using your GUI from Problem 3 in HW2, beautify your plot so that it would be acceptable in homework for a 200/300-level engineering course. Your signal should be plotted as a function of time, rather than sample index as has been our default through HW’s 1 and 2. [Hint: plot(xarray,yarray) graphs the ordered pairs (xarray(1),yarray(1)), … (xarray(end),yarray(end)), whereas plot(xarray) graphs the ordered pairs (1,xarray(1)), … (end,xarray(end)) . Both axes should be labeled (e.g., time and amplitude). x- and y-axes (time and amplitude, respectively). The title of your graph should be ‘Sinusoid: F Hz at P degrees’ where ‘F’ and ‘P’ should take on the values of the frequency and phase you have selected. [Hint: Use strcat to create a long string from shorter strings and use num2str to convert your frequency and phase variables back to a string. There are other ways to proceed, but this will work.] Provide a picture of your running GUI, and the Callback function in which you perform the plotting.
% --- Executes on button press in pushCreate. function pushCreate_Callback(hObject, eventdata, handles) % hObject handle to pushCreate (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Fs = 8192; % [Hz] sampling frequency sigdur = 1.2; % [sec] duration of signal npts = ceil(Fs*sigdur); % number of sample points n = 0:npts-1; % sample indices (1:npts is also fine) freq = str2double(get(handles.editFreq,'String')); % [Hz] user-selected freq phase = str2double(get(handles.editPhase,'String')); % [deg] user-selected phase handles.Fs = 8192; % [Hz] sampling frequency handles.sig = 0.25*sin(2*pi*n*freq/Fs + 2*pi*(phase/360)); % sinusoid %handles.sig = handles.sig(randperm(npts)); % randomize order for HW2 Problem 3 part b guidata(hObject,handles); t_val = (1:200)/handles.Fs; plot(t_val,handles.sig(1:200)); % plot the first 200 points xlabel('time [sec]'); ylabel('amplitude');

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}