%---------------------------------------------------------------------- % PHYSL 317 / BIOPH 317 / NEURO 317 / BIOENG 376 % Methods in Computational Neurobiology - Fall 2004 % % hw1p2.m - Homework #1, Problem #2 % RC circuit simulation % Simulate step responses for a family of RC values (different values of R). % % ***YOUR NAME*** % *** DATE*** %---------------------------------------------------------------------- % Initialization clear; figure(1); clf; % Define constants DT = 1; TMAX = 100; TIME = DT : DT : TMAX; % resistance and capacitance values RVALUE = [ 2, 5, 10, 20, 50]; C = 1; % Stimulus parameters IMAX = 1.0; TSTART = 10; TSTOP = 60; % loop over different R values for ival = 1:length(RVALUE) R = RVALUE(ival) ; % set initial condition v(1) = 0; % now loop over time points for itime = 2 : length(TIME) t = TIME(itime); *** compute the value of the input current I at this time-step based on TSTART, TSTOP*** *** compute dv/dt , which depends on v(itime-1), I, R and C*** % now update the voltage using Euler integration v(itime) = v(itime-1) + dvdt * DT; end % plot voltage versus time for this R value *** decide what plot symbol to use *** *** to make things simple, you can leave off the plot symbol to get started *** plot(TIME, v, ***PLOTSYMBOL***) hold on; *** add a text label somewhere near the voltage trace *** *** you need to compute an X and Y LOCATION to draw the string *** myString = ['R=' num2str(R)]; xloc = ***???***; yloc = *** ??? ***; text( xloc, yloc, myString); end *** set axis limits for the figure*** *** add title, xlabel, ylabel *** |