From: matlab_learner on 18 Mar 2010 20:13 hi all i want to eliminate the for statement...but the boundaries need to be fixed. is there a better way of writing this? i am using matlab. thanks d(1) = fi(2) - a*fi(1); d(79) = fi(80) - c*fi(81); for i = 3:79 d(i) = fi(i-1) end where a and c are scalars.
From: William Smith on 18 Mar 2010 20:31 matlab_learner <cibeji(a)gmail.com> wrote in message <91bf19f3-7065-4fe4-a6e5-1b7395c3eb8c(a)w27g2000pre.googlegroups.com>... > hi all > i want to eliminate the for statement...but the boundaries need to be > fixed. is there a better way of writing this? i am using matlab. > thanks > > d(1) = fi(2) - a*fi(1); > d(79) = fi(80) - c*fi(81); > for i = 3:79 > d(i) = fi(i-1) > end > > > where a and c are scalars. How about d(3:79) = fi(2:78). But why are you setting d(79) in the for loop and in the previous line as well?
From: matlab_learner on 18 Mar 2010 21:05 On Mar 18, 5:31 pm, "William Smith" <w...(a)commoditymodels.com> wrote: > matlab_learner <cib...(a)gmail.com> wrote in message <91bf19f3-7065-4fe4-a6e5-1b7395c3e...(a)w27g2000pre.googlegroups.com>... > > hi all > > i want to eliminate the for statement...but the boundaries need to be > > fixed. is there a better way of writing this? i am using matlab. > > thanks > > > d(1) = fi(2) - a*fi(1); > > d(79) = fi(80) - c*fi(81); > > for i = 3:79 > > d(i) = fi(i-1) > > end > > > where a and c are scalars. > > How about d(3:79) = fi(2:78). > > But why are you setting d(79) in the for loop and in the previous line as well? The problem is best solved in C. Using Matlab I am forced to shift my index by 1
|
Pages: 1 Prev: MINLP in MATLAB Next: Tridiagonal matrix - Gaussian elimination, loop |