Help with MATLAB: Rectangular Function Input & Explanation

  • MATLAB
  • Thread starter mrlala
  • Start date
  • Tags
    Matlab
In summary, the individual is new to MATLAB and seeking help with inputting a rectangular function into their code. They have searched for assistance on Google but have not found it helpful. They have provided their function and are unsure how to include the 'rect' part. They are requesting an explanation of what the function tells us. The expert suggests understanding the definition of the function and drawing it before programming it. They also remind the individual not to post homework on this forum.
  • #1
mrlala
1
0
im new to MATLAB as well as this forum to. i don't know how to input rectangular function in matlab. i had search google, but it seems non of them are helpfull enough..
here is my function:
x=exp(t)*rect(t −1/2)
i have no idea to insert the part of 'rect'..
then, could anyone please explain to me what this function tells us..
cheers.
 
Physics news on Phys.org
  • #2
mrlala said:
im new to MATLAB as well as this forum to. i don't know how to input rectangular function in matlab. i had search google, but it seems non of them are helpfull enough..
here is my function:
x=exp(t)*rect(t −1/2)
i have no idea to insert the part of 'rect'..
then, could anyone please explain to me what this function tells us..
cheers.
First, you need to understand the definition of the function, I've never heard of this function but a simple copy-paste fo 'rect' into Google directed me to Wikipedia! Did you even try this?
http://en.wikipedia.org/wiki/Rectangular_function
Secondly, the function is shifted because the defintion is for rect(t)= rect(t-0) but you have rect(t-.5). So you need to add .5 to the conditional statements of the definition, obviously without changing the output of the function; this is equivalent to redefining T = t - .5 and applying the original rules.
Third, with a simple problem like this you need to draw the function's output before programming it; in this way, you know what to expect and if your code has any errors (or worse yet, you program it correctly but don't understand the function and therefore misdraw it).
Finally, program it; and don't post homework on this page anymore! This is a page for serious non-homework questions.
 

Related to Help with MATLAB: Rectangular Function Input & Explanation

What is a rectangular function in MATLAB?

A rectangular function is a function in MATLAB that has a constant value of 1 within a specified interval and a value of 0 outside of that interval. It is commonly used in signal processing and digital filtering.

How do I input a rectangular function in MATLAB?

To input a rectangular function in MATLAB, you can use the "rectpuls" function. This function takes in two parameters - the length of the interval and the width of the pulse. For example, to create a rectangular function with a length of 10 and a pulse width of 2, you can use the code "x = rectpuls(10,2)".

How do I plot a rectangular function in MATLAB?

To plot a rectangular function in MATLAB, you can use the "plot" function. First, you need to create an array of values for the x-axis using the "linspace" function. Then, use the "rectpuls" function to create an array of values for the y-axis. Finally, use the "plot" function to plot the rectangular function. For example, you can use the code "x = linspace(-10,10,100); y = rectpuls(x,2); plot(x,y)" to plot a rectangular function with a length of 10 and a pulse width of 2.

What is the purpose of using a rectangular function in MATLAB?

The purpose of using a rectangular function in MATLAB is to simulate a signal or a filter with a specific frequency response. It can also be used to analyze and manipulate signals in areas such as digital signal processing, communications, and control systems.

What are some common applications of rectangular functions in MATLAB?

Rectangular functions in MATLAB are commonly used in signal processing and digital filtering to simulate signals and filters, in communication systems to represent digital data, and in control systems to model step inputs or disturbances.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
17K
Back
Top