here i give the script when h(1), Lss(1),Nss(1) :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
%Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
%Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
%Variable3
Nss = [2,3,4];
Var1HeightTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
%% Base(base)
Xbase = L*(0:NumberBay);
Zbase = repelem(0,1,length(Xbase));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(1)),1,length(Xbotbeam));
% replicate [X] to be the same size as [Z] for plotting:
Xcol = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol = [Zcolumn,Zbotbeam];
%% Ordinary Segment
% calculate span length of ordinary segment
Los = (L-Lss(1))/2;
Nos = Los/h(1);
Nos = round(Nos);
los = Los/Nos;
assert(logical(los*Nos*2+Lss(1)==15),"span must be 15m");
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(1)/2)+los*(0:Nos-1)].'+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(1),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Special Segment
% calculate span length of special segment
lss = Lss(1)/Nss(1);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss(1)*(0:Nss(1))+L/2-Lss(1)/2).'+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(1),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Joint
X = [Xbase,Xcol,Xos,Xss];
Z = [Zbase,Zcol,Zos,Zss];
scatter(X,Z,'filled'),grid on
%% Name Joint
jointbase = table((1:numel(Xbase))',Xbase',Zbase','VariableNames',{'ID','X','Z'});
jointcolumn = table((max(jointbase.ID)+1:numel(Xcol)+max(jointbase.ID))',Xcol',Zcol','VariableNames',{'ID','X','Z'});
jointordinarysegment = table((max(jointcolumn.ID)+1:numel(Xos)+max(jointcolumn.ID))',Xos',Zos','VariableNames',{'ID','X','Z'});
jointtopordinarysegment = jointordinarysegment(ismember(jointordinarysegment.Z,Zcolumn),:);
jointbottomordinarysegment = jointordinarysegment(ismember(jointordinarysegment.Z,Zbotbeam),:);
jointospecialsegment = table((max(jointbottomordinarysegment.ID)+1:numel(Xss)+max(jointbottomordinarysegment.ID))',Xss',Zss','VariableNames',{'ID','X','Z'});
jointtopspecialsegment = jointospecialsegment(ismember(jointospecialsegment.Z,Zcolumn),:);
jointbottomspecialsegment = jointospecialsegment(ismember(jointospecialsegment.Z,Zbotbeam),:);
%check angle
%anglespecialsegment = (Lss(1)/Nss(1))/h(1);