Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1471
Number of posts: 2147

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
xlsread help! Posted by CorBie on 13 Sept 2012 at 7:36 AM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.