I am relatively new to matlab. So I am trying out some logic in the following lines which gives me the error which I think is because one variable is over writing the other though I am not sure how.
function f = initial(R,init,num,color)
x = zeros(num,1); x(1)=init; t = 0:20:100; for i = 1:num x(i+1)= R * x(t) * (1 - x(t));
Subscript indices must either be real positive integers or logicals.
Error in initial (line 7) x(i+1)= R * x(t) * (1 - x(t));
No products are associated with this question.
The whole x(t) thing is not working. It certaintly always will break with x(0), but also with x(20) etc. if there are not 20 elements. You want to model something different than you code, but I can't tell how you should do withour application information.
Some extra tips: Avoid using word that are (or might be) reserved by MATLAB and toolboxes. You can e.g. find by using WHICH
which i -all i is a variable. built-in (C:\Program Files\MATLAB\R2012b\toolbox\matlab\elmat\i) % Shadowed
And then you find out "Oh, I overwrite complex calculation"! Here you don't fail as you don't do complex calculation and your "i" is in a function.