Hello all,
I am asking for your help with an error I keep getting with my code. First, here is my current code:
clear all;
close all;
clc;
t=0:600;
Tcoffee=(130*exp(-t/200)+70);
X0=1;
T0=0;
T=600;
h=30;
g=70;
N=T/h;
Thist=[T0:h:T];
Xhist=zeros(1,N);
Xhist(1)=X0;
for i=2:1:N+1
X=Xhist(i-1);
T=Thist(i-1);
f=(130*exp(-T/200)+g);
Xhist=X+f*h;
end
and the error i keep getting:
Index exceeds the number of array elements (1).
Error in Untitled (line 22)
X=Xhist(i-1);
Lastly, some things to note are that the value for Xhist when i type it into the command window is 6001 and not a table. What is also weird is that if i add a % infront of
becomes a 1x20 double table but then I get the error:
Unrecognized function or variable 'g'.
Error in Untitled (line 24)
f=(130*exp(-T/200)+g);
but if I change g in
to be +70, Xhist goes back to being the number 6001 again. So if anyone can shed so light on why I'm having this issue, I would be most appreciative.