GenerateGaussianInputNoise.m

#Copy and paste the following code into a file with .m extension
#Runs in Matlab and Octave
#SimulationTime and TimeIncrement are in nanoseconds
#Mean and StDev of Guassian distribution is in V
#Nominal voltage is in V

function out = GenerateGaussianInputNoise(SimulationStartTime, SimulationEndTime, TimeIncrement, Mean, StDev, NominalVoltage)

fid = fopen(‘pwlFile.in’,'w’);

for i=SimulationStartTime:TimeIncrement:SimulationEndTime

time=i;

x=randn(1)*StDev + Mean;
x=NominalVoltage + x;
fprintf(fid,’%6.5fe-9 ‘,time);
fprintf(fid,’%4.5f\n’,x);

endfor

fclose(fid);
out=1;

endfunction

3 Responses to “GenerateGaussianInputNoise.m”

  1. Austin Harney Says:

    that worked perfectly – needed to edit the .m file as my version of Matlab uses % instead of # to comment out lines,also end rather than endfor/endfunction. thanks!

  2. Hadi Says:

    Perfect!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.