필터 지우기
필터 지우기

Line breaks and and spacing in subsystem.

조회 수: 11 (최근 30일)
Deon Hargrove
Deon Hargrove 2020년 5월 1일
I created a function that finds spaces in a subsystem and erases them. The problem I am currently having is that is when I am trying to retrieve only the subsystems with blanks in their names the functions retrieves them more than once. For Example:
'ISP/Fuelproperties/liqFuelISP
'ISP/Fuelproperties/liqFuelISP
'I_sprntisp/No SPRINT Installed'
'I_sprntisp/SPRINT Installed'
'I_sprntisp/SPRINT Installed/Airless SPRINT Installed'
'I_sprntisp/SPRINT Installed/SPRINT Normal Installed'
'I_sprntisp/SPRINT Installed/Airless SPRINT Installed'
'I_sprntisp/SPRINT Installed/SPRINT Normal Installed'
The Erroror I am getting is:
The name 'liqFuelISP' already exists in 'ISP/Fuelproperties'. Note: line breaks and spaces are equivalent in names
allSubsystems = recursiveModelReferenceBlock(char(getfullname(system)),[]);
SubsystemsBlanks=find_system(allSubsystems,'RegExp','On','blockType','SubSystem','Mask','off','Name','\s');
%{
SubsystemsBlanks is duplicated subsystems names, which is causing an
error when the function is being runned. it does it's job, but
because a duplicated was created it tries to fix the same error
twice, which is not possible since it was already fixed.
%}
if(~isempty(SubsystemsBlanks))
%Save Issues List
varNames = {'Diagrams','Subsystem'};
varName = {'Subsystem'};
cellArray = {}; %we separate each port into its own row
Diagram = {};
for i=1:length(SubsystemsBlanks)
[three,four]=cellfun(@fileparts,SubsystemsBlanks(i),'uni',0);
cellArray = vertcat(cellArray,four{:});
Diagram = vertcat(Diagram,three{:});
end
%Erase Blank spaces in subsystems
for subsystem = 1:length(SubsystemsBlanks)
thissubsystem = SubsystemsBlanks{subsystem};
OldsubsystemName = get_param(thissubsystem,'Name');
SubsystemNameNoWhiteSpace = regexprep(OldsubsystemName,'[\n\r\t\s]+','');
if (~isempty(SubsystemNameNoWhiteSpace))
set_param(thissubsystem,'Name',SubsystemNameNoWhiteSpace); %Remove whitespace and any spaces
end
thisSystem = strtok(thissubsystem,'/');
save_system(thisSystem);
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by