this is my code, i save the function with fungsi.m
function dydt = fungsi(t,y,p)dydt(1) = p(1)*(1135254-y(1)-y(2))*(y(1)/(y(1)+p(4)*1135254))-(p(2)+136)*y(1);dydt(2)= p(2)*y(1)-(136+p(3))*y(2);end
this in the other file for fminsearch (filename: fmin.m) with data of y(1) and t
rng defaultt = [1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61];y = [25:24:27:22:22:22:16:11:18:18:19:24:12:22:15:10:11:11:20:10:16:21:13:13:10:12:12:12:6:13:6:9:10:10:6:10:10:4:3:6:8:8:8:13:12:12:15:4:14:12:10:12:8:8:8:5:12:20:10:12:12];fun = @(p)fungsi(p,t,y);x0 = 25;[x,fval] = fminsearch(fun,x0)
This is the error output:
Index exceeds matrix dimensions.Error in fungsi (line 2)dydt(1) = p(1)*(1135254-y(1)-y(2))*(y(1)/(y(1)+p(4)*1135254))-(p(2)+136)*y(1);Error in fmin>@(p)fungsi(p,t,y)Error in fminsearch (line 200)fv(:,1) = funfcn(x,varargin{:});Error in fmin (line 6)[x,fval] = fminsearch(fun,x0)
I want to search parameter of p (p(1) until p(4) Tell me whats wrong.. please correct me! and what should i do then for coding use ode45? I need it really soon for my research, today. PLEASE HELP! Thank you!
Best Answer