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

  • MATLAB
  • Thread starter member 428835
  • Start date
  • Tags
    Functions
But the idea should work.In summary, the person is looking for a way to create a vector using an autonomous function, and suggests using an anonymous function in Matlab to achieve this. They provide an example and ask for any ideas.
  • #1
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
  • #2
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.
 

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

1. What is "dotting" in relation to autonomous functions?

Dotting refers to the use of the dot notation (i.e. a period) to access and call functions within an autonomous system or program.

2. How does dotting differ from traditional function calling?

Traditional function calling involves using parentheses after the function name to pass in arguments, while dotting involves directly accessing a function through an object or module using the dot notation.

3. What are the advantages of using dotting for autonomous functions?

Using dotting allows for more concise and readable code, as well as easier access to nested functions within an autonomous system. It also allows for better organization of functions within an object or module.

4. Can dotting be used for all types of autonomous functions?

Yes, dotting can be used for any type of autonomous function that can be accessed through an object or module. This includes built-in functions, user-defined functions, and methods.

5. Are there any potential drawbacks to using dotting for autonomous functions?

One potential drawback is that the dot notation can become long and cumbersome if multiple nested functions need to be accessed. Additionally, using dotting may not be as efficient as traditional function calling in certain scenarios, such as when passing in multiple arguments.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
963
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Replies
1
Views
259
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
539
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
326
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
6K
Back
Top