I have a script used to plot the buildup of a concentration N(i) over time. When a variable "ice" is one, I want it to use the first equation in my loop. When "ice" is 0, I want it to use the second equation. Whenever I run it, however, it gives me an error "Subscript indices must either be real positive integers or logicals." I…can't tell what that's referring to. My code is below. Can anybody help me? Thank you!
x = linspace(0,13000,1000);ice = [1 1 1 1 1 1 1 1 1 1 1 0 0];N = 0;for i = 1:length(x) if ice(i) == 1 N(i)= N(i-1)* .880606541; else N(i)= N(i-1)+ 46050.11434; endendplot(x,N)
Best Answer