Archive
Archive for November, 2014
interpLTspice
November 8, 2014
2 comments
% This function interpolates data returned from the runLTspice function so % as to make the time vector evenly spaced. % % example usage: % asc_file = 'filename.asc'; % volt_curr_list = runLTspice(asc_file); % results = runLTspice(asc_file, volt_curr_list); % fs = 10000; % interp_results = interpLTspice(results, fs); % % By David Dorran (david.dorran@dit.ie) function data_struct = interpLTspice(data_struct, fs) %check if the data is structured as expected data_ok = 0; if(isstruct(data_struct)) data_ok = 1; if ~(isfield(data_struct,'data') && isfield(data_struct,'data_name') && isfield(data_struct,'time_vec')) data_ok = 0; end end if(~data_ok) error('The variable passed to this function is not a data structure returned from runLTspice and cannot be processed') end if~(isnumeric(fs) && length(fs) == 1 && fs > 0) error('The second parameter used in this function should be a positive number representing the sampling frequency') end try t = data_struct.time_vec(1):1/fs:data_struct.time_vec(end); catch error(sprintf('A sampling rate of %f resulted in too much data (memory limits exceeded).\n\nTry a different sampling frequency using interpLTspcice(data_struct,fs);', fs)); end for k = 1:length(data_struct.data) data_struct.data{k} = interp1(data_struct.time_vec, data_struct.data{k}, t); end data_struct.time_vec = t;
Categories: Uncategorized
LTspice Matlab, run LTspice matlab