#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
September 18, 2008 at 4:08 pm
[...] GenerateGaussianInputNoise.m [...]
July 22, 2010 at 9:23 am
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!
November 9, 2011 at 1:18 am
Perfect!