xlsread help!

Hi i am trying to replace the content of a SBML file with the content from an excel sheet. I did not write the coding and i therefore have difficulties of understanding what is going on and to fix the eventual Matlab error. I hope i have given enough information.

The excel sheet contains 504 rows and 10 columns (although not all columns are needed)
First row looks like this (columns are separated with : )

RXN_1 : alanine biosynthesis : [c] L-ALPHA-ALANINE -> D-ALANINE : NCgl0563 : alr : amino acid metabolism : 0 : 0 : 1000 : 0

function [CorModel]=createCNW(filename);
% clear all; clc;
RefModel=readCbModel('Ec_iJR904_GlcMM',1000,'SBML');

CorModel = removeRxns(RefModel,char(RefModel.rxns(1:end-1)));
CorModel.genes(1:end-1)='';
CorModel.rxnGeneMat(1:end-1)=[];
CorModel.subSystems='';

% the excel file which contains the information i want to transfer
z='Cor_3.xls';

%from here on the part that i don't understand starts, googling addNum and addTxt doesn't get me anywhere
[addNum, addTxt]=xlsread([z], 'used');

addID=addTxt(:,1);
addForm=addTxt(:,3);
addGRA=addTxt(:,4);
addSub=addTxt(:,6);
addRev=addNum(:,1);
addLB=addNum(:,2);
addUB=addNum(:,3);
addObj=addNum(:,4);

for i=1:length(addID)
CorModel = addReaction(CorModel,addID{i},addForm{i},'',addRev(i),addLB(i),addUB(i),addObj(i),addSub{i},addGRA{i},'','',0);
end

CorModel.metNames=CorModel.mets;
CorModel.metFormulas=CorModel.mets;
CorModel = removeRxns(CorModel,char(CorModel.rxns(1)));
CorModel.genes(1)='';
%CorModel.rxnGeneMat(1)=[];
CorModel.rxns=CorModel.rxns';
CorModel.lb=CorModel.lb;
CorModel.ub=CorModel.ub;
CorModel.c=CorModel.c;

cobraSolverName = 'lp_solve';
cobraSolverName = 'glpk';
LPsolverOK = changeCobraSolver(cobraSolverName, 'LP');

end


The error message from Matlab:

??? Index exceeds matrix dimensions.

Error in ==> createCglutNW at 24
addGRA=addTxt(:,4);


If i exchange the columns here from
addGRA=addTxt(:,4);
addSub=addTxt(:,6);

to

addGRA=addTxt(:,2);
addSub=addTxt(:,2);

then Matlab does the job (it is of course wrong because i don't want to use the column 2, but 4 and 6)

Hope somebody can see where it is going wrong
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories