How do I create a vector which elements are the output of another vector run through an equation?

18 views (last 30 days)
Okay so I have an equation (a polynomial) and a starting vector. What I need is for each element of the vector to be input into the polynomial and the output of that be made into a new vector. I hope that makes sense.... essentially what I have is y=x^2 p=[1;2;3;4] and what I need to happen is have some way to make a vector r such that r=[1;4;9;16]. Does anybody know how to do this?? Thanks!

Answers (1)

KSSV
KSSV on 9 Mar 2021
x = 1:4 ;
y=x.^2
y = 1×4
1 4 9 16

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!