Question

How can I do Mathematica-style

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

in Octave?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top