If you want an almost one liner:
x = 1:1:50;
f = @(z) z(1);
plot(x, arrayfun(@(n) f(A^n*v), x))
The error in what you tried comes from A^x
: x
cannot be a vector, it must be a scalar because A
is a square matrix. See the help of mpower
for more info.