function alpha = uppp2(x)N = 100; d = 75; g = 5; h = 0.1;for n = 1:xalpha(1,n) = (x+1-n) * d;endfor n = 1:Nalpha((n+1),1) = alpha(n,1) + g * h;endfor j = 2:xfor n = 1:N % index n
alpha(n+1,j) = alpha(n,j) + h * vel((alpha(n,j-1)) - alpha(n,j))endendendfunction kappa = vel(y)kappa(y >= d) = n * h * 25 / 6 % Here i want to use the same index n as in the foor loop
kappa(y == d) = 25kappa(y <= d) = g - 1end% How do I achive this? It seems like the function Kappa doesn't find the variable n.
MATLAB: Using an index in a loop as a variable in another function
functionindexingMATLAB
Best Answer