Reputation: 1
I see that I can define a range with 1:3
. I can also apply a function to a number, e.g. sin(1)
. But, how do I map the range of numbers with the function? I would like to $1,2,3 \to sin(1), sin(2), sin(3)$.
Upvotes: -1
Views: 55
Reputation: 14939
I suspect you want something like this:
[1:n; sin(1:n)].'
ans =
1.0000 0.8415
2.0000 0.9093
3.0000 0.1411
4.0000 -0.7568
or
f = @(n) sin(n)
f(1:n)
ans =
0.8415 0.9093 0.1411 -0.7568
I can explain it more thoroughly if you confirm that this is what you want to achieve.
Upvotes: 1