for loop taking output as input for the next iteration in loop

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

for loop taking output as input for the next iteration in loop

naryana.shankara
Here's my code:
%hwk1_6
clc
clear all
A = [1 1; 1 0]
X = [1 0; 0 1]
for a = 1:5
    X*A
   
end

My lab partner and I spent about an hour and a half trying to get octave to
take the output and then use it as the new input in this fashion:
Compute X k+1 = AX k , for k = 1, 2, . . . , 5 using a for loop and report
the results for each
k in the work you turn in.

We tried various methods and either got errors or whiskey tango foxtrot.  We
both know we're missing so simple.  Can you provide assistance?




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: for loop taking output as input for the next iteration in loop

Colin Macdonald-2
On 2017-08-30 07:46 PM, naryana.shankara wrote:
> for a = 1:5
>      X*A
> end
>
> Compute X k+1 = AX k , for k = 1, 2, . . . , 5 using a for loop and report
> the results for each

Have you tried "X = A*X" inside your loop?

best,
Colin

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave