Create function from a vector in matlab

In summary, the conversation discusses creating a function that relates a column vector and a time vector with the same dimensions. The function will allow for calculations such as sin(t)*f(t) where f(fstep) = c(cstep). The document attached (Chapter 1 and Chapter 2) may provide useful information for implementing this function.
  • #1
_zeQ
3
0
Hi everyone,

Lets say i have created a column vector c = [ N x 1 ] and my time vector has the same dimensions.

I want to create a function f(t) in which f(fstep) = c(cstep) where cstep is integer and fstep maybe not.
( for example f(0)=c(0), f(0.1)=c(1), ... f(10)=c(100))

As a result i will be able for example to do the calculation sin(t)*f(t).

Thanks
 
Physics news on Phys.org
  • #2
I am attaching a document that can be useful (Chapter 1 and Chapter 2). Hope this helps, of course it would be helpful if I explain step by step what you intend to implement.
regards
 

Attachments

  • Math-Tutorial.pdf
    83.8 KB · Views: 439
Last edited:

1. How do I create a function from a vector in MATLAB?

To create a function from a vector in MATLAB, you can use the "function" keyword followed by the name of the function, input arguments, and output arguments. Within the function, you can manipulate the vector using various built-in functions and operations.

2. Can I create a function from a vector with multiple input arguments?

Yes, you can create a function from a vector with multiple input arguments by specifying them after the function name, separated by commas. For example, if your vector is called "v" and you want to pass two input arguments "a" and "b" to your function, you can use the syntax "function v = myfunction(a, b)".

3. How can I specify the output arguments when creating a function from a vector?

To specify the output arguments when creating a function from a vector, you can use the syntax "function [output1, output2, ...] = myfunction(input1, input2, ...)". This will allow you to assign the results of your function to the specified output variables.

4. Is it possible to create a function from a vector in a script file?

Yes, it is possible to create a function from a vector in a script file. You can write your function in the script file, save it, and then call the function in the command window or another script file. This can be useful for organizing and reusing code.

5. Can I use a loop to create a function from a vector in MATLAB?

Yes, you can use a loop to create a function from a vector in MATLAB. You can use the "for" or "while" loop to iterate through the elements of the vector and perform operations on them. This can be useful when working with large or dynamically changing vectors.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
569
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
996
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top