Borrar filtros
Borrar filtros

how to simulate a model inside an embedded matlab function block with code have a for loop ?

1 visualización (últimos 30 días)
the block "ERROR LOOP" has a 15 i/p arguments which some are i/p to the block "OFF DESIGN MODULE" which all are sub of ('EngineModel1') i wrote the code for the embedded matlab function in ERROR LOOP block as shown with no syntax errors but when run simulation give an 2 error: as attached.
<<
if true
function yout=ERRORLOOP (VB,V7,V6,V5,V4,V3,V2,V1,E1,E7,E2,E3,E4,E5,E6)
for VB=(0.7:0.02:1.1)
TOLL =0.003;
DELTA=0.005;
ER=[E1;E2;E3;E4;E5;E6;E7];
V=[V1;V2;V3;V4;V5;V6;V7];
ERB=ones(7,1);
DV=ones(7,1);
for z=1:7;
if abs(ER(z)) > TOLL;
for w=1:7;
ERB(w)=ER(w);
DV(w)=DELTA*V(w);
end
for j=1:7;
V(j)=V(j)+DV(j);
sim('EngineModel1');
EMAT=ones(7,7);
AMAT=ones(7,1);
for i= 1:7;
EMAT(i,j)=(ER(i)-ERB(i)/DV(j));
AMAT(i)=-ERB(i);
end
V(j)=V(j)-DV(j);
end
DV(j)=AMAT(i)/(EMAT(i,j));
V(j)=V(j)+DV(j)*0.25;
sim('EngineModel1');
else
end
end
end
yout=[V VB]; end
<<
>>
>>
note: in code i have to simulate the model 'EngineModel1' inside the for loop "j" 7 times and one time after the if condition finished "z"(i.e 8 times each if condition).

Respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by