Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我看到我可以用1:3. 我还可以将函数应用于数字,例如sin(1). 但是,如何用函数映射数字范围?我想 $1,2,3 \to sin(1), sin(2), sin(3)$。
1:3
sin(1)
我怀疑你想要这样的东西:
[1:n; sin(1:n)].' ans = 1.0000 0.8415 2.0000 0.9093 3.0000 0.1411 4.0000 -0.7568
或者
f = @(n) sin(n) f(1:n) ans = 0.8415 0.9093 0.1411 -0.7568
如果您确认这是您想要实现的目标,我可以更彻底地解释它。