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

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Functions
Click For Summary
The discussion revolves around generating a vector from an autonomous function f(x,j) for use in a dot product operation. The user seeks to create a j-vector, specifically using the example function f = @(x,j) sin(x * j), to produce a vector v = [sin(x), sin(2x), sin(3x)]. A suggestion is made to utilize the anonymous function in MATLAB to create the vector, with a proposed code snippet that demonstrates how to achieve this. However, the responder notes a lack of MATLAB access, which raises uncertainty about the syntactical accuracy of the provided code.
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K