How to make an exponential function taking as input a vector?

5 views (last 30 days)
For example, if my vector is: [2], I'd like to convert this into:
[1,n]. Then, if input is:[3] -> [1,n,n^2] and so on...

Accepted Answer

John D'Errico
John D'Errico on 6 Oct 2018
inp = 3;
syms n
n.^(0:inp-1)
ans =
[ 1, n, n^2]

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!