DSPRelated.com
Forums

How to define a trapezoidal pulse in MATLAB

Started by Daniel April 6, 2007
dbell ha scritto:
> On Apr 6, 12:03 pm, gyansor...@gmail.com wrote: >> On Apr 7, 12:37 am, "Daniel" <dans...@gmail.com> wrote: >> >> >> >> >> >>> Hi all! >>> I have to define a trapezoidal pulse and then obtain it's frequency >>> spectrum. >>> These are the specifications: >>> The increasing duration is 0.1 us. >>> The decreasing duration is 0.1 us. >>> The pulse mean duration is 0.5 us. >>> The amplitude is a random variable. >>> ______ >>> / \ >>> / \ >>> ____/ \____ >>> | | | | >>> 0.1us 0.1us >>> | 0.5us | >>> How can I do that with matlab? >>> Thank you all in advance! >>> Daniel >> I would try the analytic solution. Try sub-dividing the wave-form in >> sections - you have a pulse in teh middle and what looks like a >> triangular type of wave at either end. >> Wang King- Hide quoted text - >> >> - Show quoted text - > > Alternately, could be viewed as the convolution of a short rect pulse > and a long rect pulse. > > Dirk >
ok, I knew that. the problem is that when I change the timeline (number of samples) the increase/decrease duration change. I.E. I tried it in this way: function [y] = rect(Tw) % y = rect(Tw) % Tw = rect width t = (-0.5:0.1:0.5)'; % timeline y = abs(t)<Tw/2; plot(t,y) If i try to create a rect with the function rectpuls I obtain a trapezoidal pulse and not a real rect. So, making the convolution between the two obtained rects would be a conv between two trapezoidal pulses.
Daniel wrote:

   ...

> If i try to create a rect with the function rectpuls I obtain a > trapezoidal pulse and not a real rect. So, making the convolution > between the two obtained rects would be a conv between two trapezoidal > pulses.
That's a misinterpretation on your part. Mark the points on a grid that represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), ... = 1. That's as close to a digital step as you can get. If you "plot" that by connecting the dots, the segment between y(n) and y(n+1) isn't parallel to the y axis. That's life! (Digital life, anyway.) Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
Jerry Avins ha scritto:
> Daniel wrote: > > ... > >> If i try to create a rect with the function rectpuls I obtain a >> trapezoidal pulse and not a real rect. So, making the convolution >> between the two obtained rects would be a conv between two trapezoidal >> pulses. > > That's a misinterpretation on your part. Mark the points on a grid that > represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), ... = 1. > That's as close to a digital step as you can get. If you "plot" that by > connecting the dots, the segment between y(n) and y(n+1) isn't parallel > to the y axis. That's life! (Digital life, anyway.) > > Jerry
Yes, I supposed it. So I how can I create an ideal rect??
Daniel wrote:
> Jerry Avins ha scritto: >> Daniel wrote: >> >> ... >> >>> If i try to create a rect with the function rectpuls I obtain a >>> trapezoidal pulse and not a real rect. So, making the convolution >>> between the two obtained rects would be a conv between two >>> trapezoidal pulses. >> >> That's a misinterpretation on your part. Mark the points on a grid >> that represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), ... >> = 1. That's as close to a digital step as you can get. If you "plot" >> that by connecting the dots, the segment between y(n) and y(n+1) isn't >> parallel to the y axis. That's life! (Digital life, anyway.) >> >> Jerry > > Yes, I supposed it. So I how can I create an ideal rect??
It is an ideal rectangle. Remember: in a digital data stream, what is between the samples *doesn't exist*. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
Jerry Avins ha scritto:
> Daniel wrote: >> Jerry Avins ha scritto: >>> Daniel wrote: >>> >>> ... >>> >>>> If i try to create a rect with the function rectpuls I obtain a >>>> trapezoidal pulse and not a real rect. So, making the convolution >>>> between the two obtained rects would be a conv between two >>>> trapezoidal pulses. >>> >>> That's a misinterpretation on your part. Mark the points on a grid >>> that represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), ... >>> = 1. That's as close to a digital step as you can get. If you "plot" >>> that by connecting the dots, the segment between y(n) and y(n+1) >>> isn't parallel to the y axis. That's life! (Digital life, anyway.) >>> >>> Jerry >> >> Yes, I supposed it. So I how can I create an ideal rect?? > > It is an ideal rectangle. Remember: in a digital data stream, what is > between the samples *doesn't exist*. > > Jerry
But Matlab displays it. Has it to do with interpolation, then? Does Matlab automatically interpolates?
Daniel wrote:
> Jerry Avins ha scritto: >> Daniel wrote: >>> Jerry Avins ha scritto: >>>> Daniel wrote: >>>> >>>> ... >>>> >>>>> If i try to create a rect with the function rectpuls I obtain a >>>>> trapezoidal pulse and not a real rect. So, making the convolution >>>>> between the two obtained rects would be a conv between two >>>>> trapezoidal pulses. >>>> >>>> That's a misinterpretation on your part. Mark the points on a grid >>>> that represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), >>>> ... = 1. That's as close to a digital step as you can get. If you >>>> "plot" that by connecting the dots, the segment between y(n) and >>>> y(n+1) isn't parallel to the y axis. That's life! (Digital life, >>>> anyway.) >>>> >>>> Jerry >>> >>> Yes, I supposed it. So I how can I create an ideal rect?? >> >> It is an ideal rectangle. Remember: in a digital data stream, what is >> between the samples *doesn't exist*. >> >> Jerry > > But Matlab displays it. Has it to do with interpolation, then? Does > Matlab automatically interpolates?
Matlab automatically connects the dots. Most of the time that's a convenience. Some of the time it fools you if you don't know what you're looking at. The illusion is most pronounced at discontinuities. Real discontinuities don't exist in nature, but many phenomena come close. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
Jerry Avins ha scritto:
> Daniel wrote: >> Jerry Avins ha scritto: >>> Daniel wrote: >>>> Jerry Avins ha scritto: >>>>> Daniel wrote: >>>>> >>>>> ... >>>>> >>>>>> If i try to create a rect with the function rectpuls I obtain a >>>>>> trapezoidal pulse and not a real rect. So, making the convolution >>>>>> between the two obtained rects would be a conv between two >>>>>> trapezoidal pulses. >>>>> >>>>> That's a misinterpretation on your part. Mark the points on a grid >>>>> that represent a step. y(0), y(1), ..., y(n) = 0; y(n+1), y(n+2), >>>>> ... = 1. That's as close to a digital step as you can get. If you >>>>> "plot" that by connecting the dots, the segment between y(n) and >>>>> y(n+1) isn't parallel to the y axis. That's life! (Digital life, >>>>> anyway.) >>>>> >>>>> Jerry >>>> >>>> Yes, I supposed it. So I how can I create an ideal rect?? >>> >>> It is an ideal rectangle. Remember: in a digital data stream, what is >>> between the samples *doesn't exist*. >>> >>> Jerry >> >> But Matlab displays it. Has it to do with interpolation, then? Does >> Matlab automatically interpolates? > > Matlab automatically connects the dots. Most of the time that's a > convenience. Some of the time it fools you if you don't know what you're > looking at. The illusion is most pronounced at discontinuities. Real > discontinuities don't exist in nature, but many phenomena come close. > > Jerry
Ok! Thanks! I'll try in nature's way! :-)