Creating a 'Dot' Vector for Autonomous Functions - Any Ideas?

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Functions
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
member 428835
Hi PF!

Given an autonomous function ##f(x,j)##, I am trying to create a ##j##-vector so that I can "dot" this into a ##j \times 1## vector. For example, if I have ##f = @(x,j) \sin x j## I would like to create something like ##v = [\sin x,\sin 2x, \sin 3x]## so I could dot this into a vector like ##[a,b,c]^T##.

Any ideas?
 
Physics news on Phys.org
joshmccraney said:
Hi PF!

Given an autonomous function ##f(x,j)##, I am trying to create a ##j##-vector so that I can "dot" this into a ##j \times 1## vector. For example, if I have ##f = @(x,j) \sin x j## I would like to create something like ##v = [\sin x,\sin 2x, \sin 3x]## so I could dot this into a vector like ##[a,b,c]^T##.

Any ideas?
Can't you create a vector using your anonymous (the term that is used in the Matlab docs) function? Something like this:
Matlab:
f=@(x, j) sin(x. * j)
Vec = [f(x, 1), f((x, 2), f(x, 3)]
Caveat: I don't have Matlab, so don't guarantee that my code is syntactically correct.