Help with MATLAB: Rectangular Function Input & Explanation

  • Context: MATLAB 
  • Thread starter Thread starter mrlala
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 3K views
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 definition 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.