Figure 2

Matlab Script for Log-Log Plot of C-V Data for 1N4007 Diode

% Matlab script for analysis of capacitance as a function of 
% potential for a reverse biased diode

% changes directory and  loads data
chdir c:\data\ee222\lab4
load poo.asc;
potential = poo(:,1);
capacitance = poo(:,2);

% converts to log scale and takes negative of potential, the negative
% is taken because the instrument we used only records positive
% values for potential, also converts capacitance from pF to F
capacitance = capacitance .* (10^(-12));
log_potential = -log(potential);          
log_capacitance = log(capacitance);

% fit a line to the log of the data
c=polyfit(log_potential, log_capacitance,1)
y = log_potential.*c(1) + c(2);

% plot everything
plot(log_potential,log_capacitance,'ro', log_potential,log_capacitance,'b',log_potential,y, 'g');
ylabel ('Log of Capacitance (log F)');
xlabel ('Log of Potential (log V)');
title ('Capacitance versus Potential for 1N4007 Diode');

Back to body text