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

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Functions
Click For Summary
SUMMARY

This discussion focuses on creating a j-vector for an autonomous function f(x,j) in MATLAB. The user seeks to generate a vector v containing values like [sin(x), sin(2x), sin(3x)] to perform a dot product with a j x 1 vector. A suggested solution involves using an anonymous function in MATLAB, specifically f=@(x, j) sin(x .* j), to create the desired vector. The response emphasizes the importance of ensuring correct syntax when implementing the code.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of anonymous functions in MATLAB
  • Knowledge of vector operations and dot products
  • Basic understanding of trigonometric functions
NEXT STEPS
  • Explore MATLAB anonymous functions in depth
  • Learn about vectorization techniques in MATLAB
  • Research MATLAB's dot product function and its applications
  • Study trigonometric function implementations in MATLAB
USEFUL FOR

Mathematics students, MATLAB programmers, and anyone interested in vector operations and function manipulation in MATLAB.

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
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K