Prev: qr economy LaPack
Next: How to set the seed as a 128 binary string of psudo random number generator (randn)
From: alfann on 7 Jun 2010 09:22 Hi If I have for loop, and I want increment the value of abc directly to next value in the variable DD...How? Example: DD=[1 3 4 8 9 10]; for abc= min(DD(:)) : max(DD(:)) % start from 1 to 10 by one .. .. .. ..... ... end _______ in the above example, it will increase by one from the minimum value to the maximum value, which means: 1 then 2 then 3 then 4 .... then 10 I want to set the incremental is: 1 then 3 then 4 then 8 then 9 then 10 How can I do that please?
From: Walter Roberson on 7 Jun 2010 13:41 alfann wrote: > If I have for loop, and I want increment the value of abc directly to next value in the variable DD...How? You can increment it just by writing a new value to the variable, but as soon as the next iteration of the loop starts, the variable will be reset to what would have been the next in progression if you had not changed it. There is no way to make a change to a loop variable that will "stick". You will have to do something like if abc < DD(K); next; end if
From: dpb on 7 Jun 2010 13:41 alfann wrote: > Hi If I have for loop, and I want increment the value of abc directly > to next value in the variable DD...How? > > Example: DD=[1 3 4 8 9 10]; > > for abc= min(DD(:)) : max(DD(:)) % start from 1 to 10 by one . > .. .. .... .. end > > _______ > > in the above example, it will increase by one from the minimum value > to the maximum value, which means: 1 then 2 then 3 then 4 .... then > 10 > > I want to set the incremental is: 1 then 3 then 4 then 8 then 9 then > 10 > > > > How can I do that please? If there's a derivable pattern you can use that to either generate the indices in a while loop or to load an array and use it as the iterator values; I don't see it otomh from the example given. Failing in that, either load the specific values in the array or use logic to CONTINUE for the values to skip or use a SWITCH construct or IF...ELSEIF... , etc. --
From: Robert on 7 Jun 2010 13:48 alfann <alfann.net(a)hotmail.com> wrote in message <1380396865.293654.1275931386222.JavaMail.root(a)gallium.mathforum.org>... > Hi > If I have for loop, and I want increment the value of abc directly to next value in the variable DD...How? > > Example: > DD=[1 3 4 8 9 10]; > > for abc= min(DD(:)) : max(DD(:)) % start from 1 to 10 by one > . .. .. > .... > .. > end > > _______ > > in the above example, it will increase by one from the minimum value to the maximum value, which means: > 1 then 2 then 3 then 4 .... then 10 > > I want to set the incremental is: > 1 then 3 then 4 then 8 then 9 then 10 > > > > How can I do that please? DD=[1 3 4 8 9 10]; for abc=DD disp(abc); end
From: Steven Lord on 7 Jun 2010 13:52 "alfann" <alfann.net(a)hotmail.com> wrote in message news:1380396865.293654.1275931386222.JavaMail.root(a)gallium.mathforum.org... > Hi > If I have for loop, and I want increment the value of abc directly to next > value in the variable DD...How? > > Example: > DD=[1 3 4 8 9 10]; > > for abc= min(DD(:)) : max(DD(:)) % start from 1 to 10 by one > . .. .. > .... > .. > end > > _______ > > in the above example, it will increase by one from the minimum value to > the maximum value, which means: > 1 then 2 then 3 then 4 .... then 10 > > I want to set the incremental is: > 1 then 3 then 4 then 8 then 9 then 10 for abc = DD % do stuff end When you use this syntax, the FOR loop will iterate over the columns of DD, assigning each in turn to the variable abc. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Next
|
Last
Pages: 1 2 3 Prev: qr economy LaPack Next: How to set the seed as a 128 binary string of psudo random number generator (randn) |