MATLAB Help with MATLAB: Rectangular Function Input & Explanation

  • Thread starter Thread starter mrlala
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
To input a rectangular function in MATLAB, it's essential to understand its definition and how it operates. The discussion highlights the need to adjust the function for a shifted rectangular function, specifically rect(t - 1/2), which requires modifying the conditional statements accordingly. It suggests redefining the variable to account for the shift while maintaining the original function's output. Additionally, before coding, it's recommended to visualize the function's output to anticipate results and identify potential errors. Lastly, the forum emphasizes that this platform is intended for serious inquiries rather than homework-related questions.
mrlala
Messages
1
Reaction score
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
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.
 

Similar threads

Replies
8
Views
3K
Replies
9
Views
3K
Replies
4
Views
2K
Replies
7
Views
8K
Replies
5
Views
8K
Replies
5
Views
1K
Replies
4
Views
4K
Back
Top