<div dir="ltr">Hi Stefan,<div><br></div><div>I did try that before, but got an error - "Submatrix incorrectly defined"</div><div><br></div><div>Lester</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 15 Aug 2021 at 10:56, Stefan Du Rietz <<a href="mailto:sdr@durietz.se">sdr@durietz.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 2021-08-15 09:00, Lester Anderson wrote:<br>
> Hello,<br>
> <br>
> Basic query. I have a simple code that applies the Collatz conjecture <br>
> equation (3n+1) by running a function and then runs a loop over the <br>
> values stored in prime (the first 8 Prime numbers):<br>
> <br>
> clear<br>
> <br>
> exec('collatz.sci',-1);<br>
> <br>
> prime = primes(20);<br>
> <br>
> for i = 1:length(prime)<br>
> [ns, seq]=collatz(prime(i))<br>
> end<br>
> <br>
> As it stands, this just runs to the end (i=8) and the value 19. How can <br>
> I get the code to write the results of each loop pass into the variables <br>
> ns and seq, such that each contains the results of the 8 passes?<br>
> <br>
> Can no longer search the forums online from the website.<br>
> <br>
> Thanks<br>
> Lester<br>
<br>
<br>
// Before the for loop:<br>
ns = zeros(prime);<br>
seq = ns;<br>
<br>
// Changed for loop<br>
for i = 1:length(prime)<br>
[ns(i), seq(i)]=collatz(prime(i))<br>
end<br>
<br>
Regards<br>
Stefan<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
</blockquote></div>