Info
This question is closed. Reopen it to edit or answer.
I would like to vectorize my code is it possible
1 view (last 30 days)
Show older comments
I would like to vectorize my code is it possible for this type of for loop where(iter,optvar,state,alg are fixed variable)
for n=1:iter-1
fn=Eqn(h*n-1,y(optvar*(n-1)+1:1:optvar*(n-1) + state+alg));
fnp1=Eqn(h*n,y(optvar*n+1:1:optvar*n+state+alg));
for m= 1:state
ceq(2*state*(n-1)+m)=y(optvar*n+m)-y(optvar*(n-1)+m)-(beta/gamma)*fnp1(m)*h-(1- beta/gamma)*fn(m)*h-(1/2-beta/gamma)*y(optvar*(n-1)+state+alg+m)*h^2;
end
for m=state+1:2*state
ceq(2*state*(n-1)+m) = y(optvar*n+alg+m)-(1/gamma)*(fnp1(m-state)/h)+(1/gamma)*(fn(m-state)/h)-(1-1/gamma)*y(optvar*(n-1)+alg+m);
end
end
i have tried this but it is showing error like matrix dimension must agree...and minus operation not possible
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!