views:

175

answers:

1

How can I do Mathematica-style

a = Table[2^(2 k) + 1, {k, 1, 3}]
Last[a], First[a]
Append[a,3]

in Octave?

+3  A: 

I'd do this as

2 .^ (2 * [1:3]) + 1

Here, [1:3] stands for the vector [1,2,3] and .^ denotes entry-wise exponentiation.

Added after question was edited:
These are rather basic questions. I think you need to spend some time learning Octave; for instance, read through this tutorial.

Jitse Niesen
Thank you, very useful tutorial.
HH