Location: BG_TCC @ 9013e062f457 / parameter_fitting / load_matrix.m

Author:
Shelley Fong <s.fong@auckland.ac.nz>
Date:
2022-02-25 14:06:24+13:00
Desc:
Init
Permanent Source URI:
https://models.cellml.org/workspace/831/rawfile/9013e062f4570d3150bcc4df8b75ce3f956bc17a/parameter_fitting/load_matrix.m

function matrix = load_matrix(stoich_path)

stoich_file_id = fopen(stoich_path,'r');

stoich_file_data = textscan(stoich_file_id,'%s','delimiter','\n');
fclose(stoich_file_id);

num_rows = length(stoich_file_data{1});
num_cols = sum(stoich_file_data{1}{1} == ',')+1;

matrix = zeros(num_rows,num_cols);

for i_row = 1:num_rows
    line_str = stoich_file_data{1}{i_row};
    line_split = regexp(line_str,',','split');
    
    for i_col = 1:num_cols
        matrix(i_row,i_col) = str2double(line_split{i_col});
    end
end


end