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.

Simulink matlab function block

Status
Not open for further replies.

MihaPiha

Newbie level 1
Newbie level 1
Joined
Jun 19, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Hello, Sorry on my English... I have one problem, maybe somebody can solve it... I am working with multi - winding transformers. I have 9 different windings and during the simulation i change it (from 1 to 9). When I am changing this windings, I am watching what happend with losses in closed-loop arrangement of feeders... I would like to make a function, wich found me the minimum of looses and on the end set my multi - winding transformer on that position, where are looses minimum. My inpout is 17001. And i have another problem....i have to watch losses in specific time. Do you have some diference suggestions, how can I solve this problem?? So i wrote a function on function block:

function C = fcn(Pr_C)
% #eml
% 1.odcep.--------------------------------------------
for j1 = 1400:1800
if j1==1400;
minimum1=Pr_C(j1);
if minimum1>Pr_C(j1)
minimum1=Pr_C(j1);
mesto1=j1;
end
end
end
% 2.odcep---------------------------------------------------------
for j2 = 2800:3300
if j2==2800;
minimum2=Pr_C(j2);
if minimum2>Pr_C(j2)
minimum2=Pr_C(j2);
mesto2=j2;
end
end
end
% 3.odcep---------------------------------------------------------
for j3 = 4000:4400
if j3==4000;
minimum3=Pr_C(j3);
if minimum3>Pr_C(j3)
minimum3=Pr_C(j3);
mesto3=j3;
end
end
end
% 4.odcep---------------------------------------------------------
for j4 = 5400:5800
if j4==5400;
minimum4=Pr_C(j4);
if minimum4>Pr_C(j4)
minimum4=Pr_C(j4);
mesto4=j4;
end
end
end
% 5.odcep---------------------------------------------------------
for j5 = 6800:7100
if j5==6800;
minimum5=Pr_C(j5);
if minimum5>Pr_C(j5)
minimum5=Pr_C(j5);
mesto5=j5;
end
end
end
% 6.odcep---------------------------------------------------------
for j6 = 8100:8600
if j6==8100;
minimum6=Pr_C(j6);
if minimum6>Pr_C(j6)
minimum6=Pr_C(j6);
mesto6=j6;
end
end
end
% 7.odcep---------------------------------------------------------
for j7 = 9400:9600
if j7==9400;
minimum7=Pr_C(j7);
if minimum7>Pr_C(j7)
minimum7=Pr_C(j7);
mesto7=j7;
end
end
end
% 8.odcep---------------------------------------------------------
for j8 = 10800:11200
if j8==10800;
minimum8=Pr_C(j8);
if minimum8>Pr_C(j8)
minimum8=Pr_C(j8);
mesto8=j8;
end
end
end
% 9.odcep---------------------------------------------------------
for j9 = 11700:11900
if j9==11700;
minimum9=Pr_C(j9);
if minimum9>Pr_C(j9)
minimum9=Pr_C(j9);
mesto9=j9;
end
end
end
% 10.odcep---------------------------------------------------------
for j10 = 13000:13800
if j10==13000;
minimum10=Pr_C(j10);
if minimum10>Pr_C(j10)
minimum10=Pr_C(j10);
mesto10=j10;
end
end
end
% 11.odcep---------------------------------------------------------
for j11 = 14600:15100
if j11==14600;
minimum11=Pr_C(j11);
if minimum11>Pr_C(j11)
minimum11=Pr_C(j11);
mesto11=j11;
end
end
end
% 12.odcep---------------------------------------------------------
for j12 = 16000:16400
if j12==16000;
minimum12=Pr_C(j12);
if minimum12>Pr_C(j12)
minimum12=Pr_C(j12);
mesto12=j12;
end
end
end
C=min([
minimum1,
minimum2,
minimum3,
minimum4,
minimum5,
minimum6,
minimum7,
minimum8,
minimum9,
minimum10,
minimum11,
minimum12])
Thanks, Miha
 

I guess there is a bug in your code - each your for loop executed only at first step and then no operation.
Should be like this:
minimum1=Pr_C(1400);
for j1 = 1401:1800
if minimum1>Pr_C(j1)
minimum1=Pr_C(j1);
mesto1=j1;
end
end

but there is a better way:
[minimum1, mesto1] = min(Pr_C(1400:1800));
and so on.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top