|
|
Recursive loop
Hi,
I want to compute the following loop:
a=2
for k=0:100
x=a*x;
end
My problem is I only get the last value x(k=100).
How can I "collect" all the x(k) in a vector?
thanks in advance
feelaex
|
|
0
|
|
|
|
Reply
|
feelaex
|
11/19/2010 1:37:04 PM |
|
> Hi,
>
> I want to compute the following loop:
>
> a=2
> for k=0:100
>
>
> x=a*x;
>
> end
>
> My problem is I only get the last value x(k=100).
>
> How can I "collect" all the x(k) in a vector?
>
> thanks in advance
> feelaex
a = 2;
n = 100;
x0 = 1.0;
x = zeros(n);
x(1) = x0 ;
For k = 1:(n-1)
x(k+1)=a*x(k);
end
Best wishes
Torsten.
|
|
0
|
|
|
|
Reply
|
Torsten
|
11/19/2010 9:10:55 AM
|
|
|
1 Replies
239 Views
(page loaded in 0.026 seconds)
Similiar Articles: Recursive Programming and Assembly Language - comp.lang.asm.x86 ...Of course, you might argue that this is spaghetti coding and defeats the whole purpose of using tail recursion (rather than loops) for inductive proof purposes. function blocking waiting for user interaction - comp.lang ...I also tried using a recursive function, (check value=null, if it is, recheck), but Firefox and IE apparently don't like what may seem like an unending recursive loop. Recursive interpolation function - comp.databases.filemaker ...Recursive loop - comp.soft-sys.matlab Recursive interpolation function - comp.databases.filemaker ... I'm looking to write a recursive function interpole some values with ... Nested loop with function - comp.soft-sys.matlabRecursive loop - comp.soft-sys.matlab Nested loop with function - comp.soft-sys.matlab Can anyone help me? I know its suppost to be in a nested loop and ... nested ... Infinite Loop in Code -- Logic Error - comp.lang.rubyRecursive loop - comp.soft-sys.matlab recursion multiplication logic question tia ... idxlabel <= size(c,2) Ah, but can you code it without an explicit loop? ... of ... generate/genvar, for loop and procdural (always/initial) block ...I have written 2 verilog modules, both of them are using for loops. though the for ... Programming and Assembly Language - comp.lang.asm.x86 ... #endmacro procedure recursive ... Contours to polygons - comp.soft-sys.matlabWalter Roberson <roberson@hushmail.com> wrote in message > Ah, but can you code it without an explicit loop? ;-) > > (I have a mental outline for a recursive ... File Name for each iteration in for-loop - comp.soft-sys.matlab ...Recursive iteractive function - comp.soft-sys.matlab collecting data in loops - comp.soft-sys.matlab File Name for each iteration in for-loop - comp.soft-sys.matlab ... Find minimum value in array - comp.soft-sys.matlabI need to use recursion. This is what i have so far: function [m n] = recursiveMin(A ... Well you don't want an "if" there (where you're stuck), you want a > "for" loop ... NASM - Official Recursive Macro Support! - comp.lang.asm.x86 ...New NASM Directives: * %rmacro: Recursive Macro, can be called arbitrarily deep (really high limit [2^20] set to catch infinite loops.) * %irmacro: Same as above, except ... Recursion - Wikipedia, the free encyclopediaThis of course immediately creates the possibility of an endless loop; recursion can only be properly used in a definition if the step in question is skipped in certain ... Recursive loop definition of Recursive loop in the Free Online ...infinite loop. A series of instructions that are constantly repeated. Also called an "endless loop," it can be caused by an error in the program or be intentional ... 7/22/2012 6:33:28 AM
|
|
|
|
|
|
|
|
|