Matlab S-Function coding for U-Shaped Wave

Thread Starter

zkrhrmli

Joined May 6, 2018
12
Hi.

I am working on Multilevel Inverter Cascaded H-Bridge with modified carrier.
I am trying to change from triangular carrier to U-shaped carrier but i dont know to change the coding. I am using S-Function in Matlab Simulink.

I am trying to generate waveform like the picture below.
 

Attachments

Thread Starter

zkrhrmli

Joined May 6, 2018
12
I already did -- but instead of even exploring the suggestion, you just blew it off.

Perhaps in the future you might think twice about that.
I am sorry but i am not aware of blewing you off. Btw, english is not my first language so there might be something that i dont understand or i could not deliver properly. Sorry for that.

How do you generate the waveform as attached?
 

WBahn

Joined Mar 31, 2012
30,084
I am sorry but i am not aware of blewing you off. Btw, english is not my first language so there might be something that i dont understand or i could not deliver properly. Sorry for that.

How do you generate the waveform as attached?
I ALREADY told you how:

I don't know how close it would be, but it looks like the bottom half of a sinusoid.
But you dismissed it without even trying it:

The top is like triangular and the bottom is like sinusoidal.
So why don't you go back and actually TRY the suggestion that I made?

HINT: The answer to how close it would be to what you are looking for is:

This is exactly what i am looking for!
 

Thread Starter

zkrhrmli

Joined May 6, 2018
12
I ALREADY told you how:



But you dismissed it without even trying it:



So why don't you go back and actually TRY the suggestion that I made?

HINT: The answer to how close it would be to what you are looking for is:

I was only trying to explain more on the graph and i am sorry I am poor with coding. I am not sure how to generate half sinusoidal. How can i do that? What equation would suit that waveform?
 

WBahn

Joined Mar 31, 2012
30,084
Now that you know the basic idea that will work, it's time for YOU to put in some effort to take it from there. If someone else does your coding for you, you remain someone that is poor with coding. You can't expect that there's always going to be someone there to hand you a complete solution on a silver platter -- if there were, there would no reason for a prospective employer or customer to hire you.
 

Thread Starter

zkrhrmli

Joined May 6, 2018
12
I used;

f1=50; % sine freq
f2=2000; % triangular freq
w1=2*pi*f1;
w2=2*pi*f2;
MD=1.0; %modulation inde

car=(MD)*(8/pi/pi)*[cos(w2*u(1))+(1/9)*cos(3*w2*u(1))+(1/25)*cos(5*w2*u(1))+(1/49)*cos(7*w2*u(1))];

where car produces traingular wave.
i changed cos tu sine and get a sinusoid.

would you mind looking to my coding and point my mistake?
im a student and are looking foward if you could teach me.
 

WBahn

Joined Mar 31, 2012
30,084
What you have for car is just the first few terms of the Fourier Series (for a triangle way, I'm presuming).

Just take the bottom part of a sine wave (or cosine wave, same difference).

Plot sin(wt) for a bunch of cycles.

y1 = sin(wt)

Now flip the bottom lobes upward by taking absolute value.

y2 = abs(y1)

Now invert that to make them all negative

y3 = -y2

You can get the same effect by squaring and then taking the square root.

y4 = -sqrt(sin(wt)^2)
 

Thread Starter

zkrhrmli

Joined May 6, 2018
12
Thank you so much sir. Sorry for the delayed respond, I had final exams and project ongoing at the school.

Exactly, it is the terms of the Fourier Series.

Sir, I tried using the absoulte concept as suggested as below;

function sys = mdlOutputs(t,x,u)
f1=50; % sine freq
f2=2000; % triangular freq
w1=2*pi*f1;
w2=2*pi*f2;
MD=2.0 ; %modulation inde
% A=sin(w1*u(1));

ref=1*sin(w1*u(1)); %sine

car=[abs(MD*sin(w2*u(1)))];
car1=(car/4)+((2*MD)/8);
car2=(car/4)+0;
car3=(car/4)-((1*MD)/4);
car4=(car/4)-((2*MD)/4);


I tried to change the angle so that the waveform could be steeper or vice versa.
Instead of changing the frequency, is there any other suggested method that could be used?

Thank you in advance.
 
Top