Newbie problem... No idea what is wrong with this, and I swear it was working earlier with exact same code :|
Show older comments
Apologies if this is a silly question, but I am failry new to this. Can anyone tell me how to fix this! Here's my error:
??? Attempted to access a(1); index out of bounds because numel(a)=0.
Error in ==> costv5 at 11
F=a(1)*(t^2)+a(2)*t+a(3);
Here's my code (apologies if it's messy!):
function J=costv5(EnzymeFlowrate,a1,a2,a3,a4);
global a T Y t y F e g p z
a1=e;
a2=g;
a3=p;
a4=z;
%F=a;
%F=a(1)*t+a(2);
F=a(1)*(t^2)+a(2)*t+a(3);
[t,y]=ode45('problem2v2',[0 200],[e g p z]);
d1=178;
d2=100;
d3=5;
% y specifying the matrix we are taking the rows from (number specifies
%column)
Y=[y(:,1) y(:,2) y(:,3)./10 y(:,4)];
T=t;
P=y(end,[3]);
Z=y(end,[4]);
%EnzymeFlowrate=y(end,[5]);
t=length (3);
J=-(P-(d1*(exp(-P/d2)))-(d3*Z));
end
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!