Problem: (100 points) Create a script to do the following i) Read in the voltage
ID: 2084531 • Letter: P
Question
Problem: (100 points) Create a script to do the following i) Read in the voltage and current data using load command from the filename shown in the parameters file for this assignment. ii) Use the least squares method shown in class to estimate the parameters I and V in the diode model: 1er . Name your Matlab variables for the estimates l-hat and VT-hat. Use the fprintf function to print the numerical results to a text file named diode_param_estimates.txt You'll need to study the help info for fprintf. You'll have to use fopen, and you should use fclose before the end of your script. Don't just print the numbers out, use a format string like ' 1-hat %g Amps ' with your fprintf function, etc. Your text file will consist of only two lines iii) Use your estimates, 1 and , with the given diode model and the data given for v to plot the currenti (on the vertical axis) with v on the horizontal axis using the plot function along with the given data from the file. Your plot command will look something like figure; plot (v-data, i-data,'·',V, data, i-hat,'-') Also on a separate plot (be sure and use the figure; command), plot the same data using the semilogy function On each plot, indicate which curve goes with which variable using the legend command. Perhaps something like: legend ( ' | { data) ' , ' { hat } ' ) Do not enter any numbers in by hand. To get the size of the data arrays, etc., use the size function Print your script file, any function files, the output file diode_param estimates.txt and plots to turn in You are not required to create any functions, but if you do be sure and submit a printout of them as well Remember, I should be able to type in the scripts and functions you submit and be able to produce your results using only my installation of Matlab Note that the parameter, 1, is typically a very small number, ie., 1010IExplanation / Answer
%%% Illustrate FM modulation and demodulation using triangl function %%% Defining message signal as a triangle signal, in real life however, this %%% could be anything like voice signal etc. that we would want to transmit function ExampleFM clear all; clf; ts=1e-4; % sampling interval t=-0.04:ts:0.04; Ta=0.01; % Use triangl function to generate message signal m_sig=triangl((t+0.01)/Ta)-triangl((t-0.01)/Ta); %Lm_sig=length(m_sig1); Lfft=length(t); % defining DFT (or FFT) size Lfft=2^ceil(log2(Lfft)) % making Lfft a power of 2 since this makes the fft algorithm work fast M_fre=fftshift(fft(m_sig,Lfft)) % i.e. calculating the frequency domain message signal, % fft algorithm calculates points from ) to Lfft-1, hence we use fftshift on this % result to order samples from -Lfft/2 to Lfft/2 -1 freqm=(-Lfft/2:Lfft/2-1)/(Lfft*ts) % Defining the frequency axis for the frequency domain DSB modulated signal B_m=100; % bandwidth of the signal is B_m Hz h=fir1(80,[B_m*ts]) % defining a simple lowpass filter with bandwidth B_m Hz kf=160*pi; m_intg=kf*ts*cumsum(m_sig); s_fm=cos(2*pi*300*t+m_intg) s_pm=cos(2*pi*300*t+m_sig) Lfft=length(t); % defining DFT (or FFT) size Lfft=2^ceil(log2(Lfft)+1) % increasing Lfft by factor of 2 S_fm=fftshift(fft(s_fm,Lfft)); % obtaining frequency domain modulated signal S_pm=fftshift(fft(s_pm,Lfft)); % obtaining frequency domain modulated signal freqs=(-Lfft/2:Lfft/2-1)/(Lfft*ts); % Defining the frequency axis for the frequency domain DSB modulated signal %%% Demodulation % Using an ideal low pass filter with bandwidth 200 Hz s_fmdem=diff([s_fm(1) s_fm])/ts/kf s_fmrec=s_fmdem.*(s_fmdem>0); s_dec=filter(h,1,s_fmrec) Trange=[-0.04 0.04 -1.2 1.2] % axis ranges for signal, this specifies the range of axis for the plot, the first two parameters are range limits for x-axis, and last two parameters are for y-axis Frange=[-600 600 0 300] % axis range for frequ
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.