Added matlab code samples.

All of these code samples currently are mis-identified in my repositories. I'm
donating them to the cause.
This commit is contained in:
Jason Moore
2013-01-30 13:12:45 -08:00
parent 121f096173
commit 9bb230d7c8
17 changed files with 2121 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
function par = par_text_to_struct(pathToFile)
% function par = par_text_to_struct(pathToFile)
% Returns a structure of the parameters that were stored in a csv text file.
%
% Parameters
% ----------
% pathToFile : string
% Path to a text file containing the benchmark parameters for a single
% bicycle. The parameters should be on seperate lines and take this form:
%
% c = 0.08+/-0.01
% lam = 0.31
%
% Returns
% -------
% par : structure
% A structure containing the bicycle parameters.
fid = fopen(pathToFile);
data = textscan(fid, '%s %s', 'delimiter', '=');
fclose(fid);
names = strtrim(data{1});
vals = strtrim(regexp(data{2}, '+/-', 'split'));
for i = 1:length(names)
v = vals{i};
par.(names{i}) = str2num(v{1});
end