Line breaks and and spacing in subsystem.
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Event Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!