For loop is not repeating the specified number of times
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to model Butler-Volmer enzyme kinetics in Matlab. Currently, I am trying to produce an array of values for the rates based on a distance d parameter for all of the potentials the model will be at. The direction right now is to use a for loop for the d parameter, but the for loop is not repeating the specified number of times. Instead, a constant value is used for the for loop value (d=12). An array is created when no for loop is used, but then I have run into the problem that matrix dimensions don't match and the k0 * the rest can't be computed. For a description of how I want this to run, for every time point, the values kred and kox should be calculated for every d value.
The code in question (where the constants, a, F, R, T, and Eo are predefined):
v = 0.1;
tfinal = -1.5/v;
tStep = 0.1;
tspan = 0:tStep:tfinal;
t = tspan;
En = Ei + v * t;
for d = 4:0.1:12
k0 = 225000 * exp(-d);
kred = k0 * exp(((-a * F)/(R * T)) * (En - Eo));
kox = k0 * exp((((1-a) * F)/(R * T)) * (En - Eo));
end
And for future reference, I hope the solution can be something that is multipled in a differential equation, such as:
dAdt = -kred*A + kox*B
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!