add_line connection for to column cells
Hi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
endHi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
end Hi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
end matlab, simulink MATLAB Answers — New Questions