Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MATLAB/Simulink input specification

Status
Not open for further replies.

Rtg

Newbie level 4
Joined
Jun 1, 2016
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35
I want to implement the following signal:



I(t) = 500*(sin(pi.t/0.3))^2, t belongs {0,Ts}

= 0, t belongs {Ts,T}

Here, T = 0.8 and Ts = 0.3

The code I tried:

Code:
t = 0 : 0.001 : 25;         
d = 0 : 0.8 : 25;           
y = pulstran(t,d,'rectpuls',0.3);
ut = 500.*((sin(pi*t/0.3)).^2).*y;
plot(t,ut)
xlabel 'Time (s)', ylabel Waveform

The generated waveform deforms greatly, for example the generated waveform does not consist of uniformly spaced peaks.

Edit: Modified the code but still issues remain.

Code:
    t = 0.01 * [0:3000]';         
    d = 0.8 * [0:1500]';           
    y = pulstran(t,d,'rectpuls',0.3);
    ut = 500.*((sin(pi*(t-floor(t/0.8)*0.8)/0.3)).^2).*y;
    plot(t,ut)

Mainly, instead of 1 peak for the 0.3s ON state, there are two peaks.

 
Last edited by a moderator:

I want to implement the following signal:

It is not clear the reason for you multiply a pulse train against the signal of interest.
Why don't you simply do something like that ?

Code:
t = 0 : 0.001 : 25;         
ut = 500.*((sin(pi*t/0.3)).^2);
plot(t,ut);
 

I want to implement a code (for Simulink input) which is ON for 0 to 0.3 seconds. Than OFF (0) for 0.3 to 0.8s. Again, ON for 0.8 to 1.1s and OFF for 1.1 to 1.4s. And so on. Your code will implement a sinusoidal wave only while I wish to implement a time varying function.
 

Ok, now I got what you wish. Anyway, note that you are somewhat modulating the sinusoidal wave with a pulse train having a fundamental frequency with the same magnitude order. What do you think about reduce the amount of sampled pulses from 25 to something close to 2 or 3 to see in a magnified view what waveform is really being created. Additionally, you should reduce the time step in order to keep the resolution acceptable.
 

I tried that too. But I am still unable to figure out the reason of the two peaks in every 0.3s ON cycle, while it should generate 1 peak per ON state. Besides I need to generate this signal for 30s to really see the output of the system.
 

While we do not see in an enlarged view the waveform of each pulse, we can not have the real notion of what is really happening.
 

Here is an enlarged view of the erroneous waveform being generated.

 

I would recommend you plot separately each haveform...

Code:
pulstran(t,d,'rectpuls',0.3)
500.*((sin(pi*(t-floor(t/0.8)*0.8)/0.3)).^2)

...and both multiplied.

As far as I can see, the math is working exactly as expected. The pulse train is acting as a rectangular window function, but not at an even integer fraction of the sine wave, which is being therefore faceted.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top