Corrected code with asociated simulink file is here:
clc
clear all
load_system('Commenting_Programmatic')
Num_7L=2
Num_7M= 2
Status_7L= 'on'; % Comment status
Status_7M= 'off';
for kk= 1: Num_7L
EV_7L_names= strcat('E7kW_Long Range',num2str(kk));
fullnames= getfullname(Simulink.findBlocks('Commenting_Programmatic','Name',EV_7L_names));
path= string(fullnames);
set_param(path,'Commented',Status_7L)
end
for ll= 1: Num_7M
EV_7M_names= strcat('E7kW_Medium Range',num2str(ll));
fullnames= getfullname(Simulink.findBlocks('Commenting_Programmatic','Name',EV_7M_names));
path= string(fullnames);
set_param(path,'Commented',Status_7M)
end