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:
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.
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.
Best Answer
I still don't understand what your period is, so I generated two ways to do this. The first method creates a mod vector of the time and generates a zero vector, the zero vector zeros out the data. As shown in the first figure.
This one creates a gap in between each \$ sin^2(t)\$ function, it does this by creating an time vector with zeros in it and then replicating the vector. I didn't use the same time periods so you would have to go through the code and figure it out for yourself.