![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1681016/image.png)
how to writefile string as a text-file with function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi guys, im trying to create files containing text which i defined by variable (see line 87).
i found error like this :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1680981/image.png)
the current result :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1680986/image.png)
it is supposed to be :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1680991/image.png)
HERE I GIVE MY CODE :
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];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),'VariableNames',{'VariantID','Height','Length','Number'});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
idx = unique(Zbotbeam(:).');
Zbottombeam{ijk,:} = idx;
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/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(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).'+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},'filled'),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))',Xbase{ijk,:}',Zbase{ijk,:}','VariableNames',{'ID','X','Z'});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))',Xcol{ijk,:}',Zcol{ijk,:}','VariableNames',{'ID','X','Z'});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))',Xos{ijk,:}',Zos{ijk,:}','VariableNames',{'ID','X','Z'});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))',Xss{ijk,:}',Zss{ijk,:}','VariableNames',{'ID','X','Z'});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))',totalspan,anglespecialsegment','VariableNames',{'VariantID','Total Span','Angle'});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))',jointbase','VariableNames',{'VariantID','Joint Base'});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))',jointcolumn','VariableNames',{'VariantID','Joint Column'});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))',jointtopordinarysegment','VariableNames',{'VariantID','Joint Top Ordinary Segment'});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))',jointbottomordinarysegment','VariableNames',{'VariantID','Joint Bottom Ordinary Segment'});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))',jointtopspecialsegment','VariableNames',{'VariantID','Joint Top Special Segment'});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))',jointbottomspecialsegment','VariableNames',{'VariantID','Joint Bottom Special Segment'});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
Zbottombeam{ijk} = table((1:numel(Zbottombeam{ijk,:}))',Zbottombeam{ijk,:}','VariableNames',{'VariantID','Z Bottom Beam'});
Zbottombeam = Zbottombeam(VariantIDPassed);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)',jointIcolumn',jointJcolumn','VariableNames',{'Frame ID','JointI','JointJ'});
end
%% Name the Frame
% top ordinary segment (TOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H*Ns),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew1{i,1})-1
jointI(j) = jointTOSnew1{i,1}.ID(j);
jointJ(j) = jointTOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(framecolumn{i,1}.("Frame ID"));
frameTOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
%eliminate special segment
frameTOS1{i,1}(median(1:height(frameTOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew2{i,1})-1
jointI(j) = jointTOSnew2{i,1}.ID(j);
jointJ(j) = jointTOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS1{i,1}.("Frame ID"));
frameTOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
%eliminate special segment
frameTOS2{i,1}(median(1:height(frameTOS2{i,1})),:) = [];
end
frameTOS = cellfun(@(varargin)vertcat(varargin{:}),frameTOS1,frameTOS2,'UniformOutput',false);
%% Name the Frame
% bottom ordinary segment (BOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endBOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i}.Z),:);
jointBOS{i,:} = vertcat(jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i},endBOS{i});
jointBOSnew1{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(1)),:),2);
jointBOSnew2{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(2)),:),2);
jointBOSnew{i,:} = vertcat(jointBOSnew1{i},jointBOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBOSnew1{i,1})-1
jointI(j) = jointBOSnew1{i,1}.ID(j);
jointJ(j) = jointBOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS{i,1}.("Frame ID"));
frameBOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
%eliminate special segment
frameBOS1{i,1}(median(1:height(frameBOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ =0;
for j = 1:height(jointBOSnew2{i,1})-1
jointI(j) = jointBOSnew2{i,1}.ID(j);
jointJ(j) = jointBOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS1{i,1}.("Frame ID"));
frameBOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
%eliminate special segment
frameBOS2{i,1}(median(1:height(frameBOS2{i,1})),:) = [];
end
frameBOS = cellfun(@(varargin)vertcat(varargin{:}),frameBOS1,frameBOS2,'UniformOutput',false);
%% Name the Frame
% top special segment (TSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointTSSnew1{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H),:),2);
jointTSSnew2{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H*Ns),:),2);
jointTSSnew{i,:} = vertcat(jointTSSnew1{i},jointTSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew1{i,1})-1
jointI(j) = jointTSSnew1{i,1}.ID(j);
jointJ(j) = jointTSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS{i,1}.("Frame ID"));
frameTSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew2{i,1})-1
jointI(j) = jointTSSnew2{i,1}.ID(j);
jointJ(j) = jointTSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS1{i,1}.("Frame ID"));
frameTSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
frameTSS = cellfun(@(varargin)vertcat(varargin{:}),frameTSS1,frameTSS2,'UniformOutput',false);
%% Name the Frame
% bottom special segment (BSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointBSSnew1{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(1)),:),2);
jointBSSnew2{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(2)),:),2);
jointBSSnew{i,:} = vertcat(jointBSSnew1{i},jointBSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew1{i,1})-1
jointI(j) = jointBSSnew1{i,1}.ID(j);
jointJ(j) = jointBSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS{i,1}.("Frame ID"));
frameBSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew2{i,1})-1
jointI(j) = jointBSSnew2{i,1}.ID(j);
jointJ(j) = jointBSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBSS1{i,1}.("Frame ID"));
frameBSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
frameBSS = cellfun(@(varargin)vertcat(varargin{:}),frameBSS1,frameBSS2,'UniformOutput',false);
%% Name the Frame
% diagonal ordinary segment (DOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tosleft{i,:} = frameTOS{i,1}(1:2:end,:);
tosright{i,:} = frameTOS{i,1}(2:2:end,:);
bosleft{i,:} = frameBOS{i,1}(1:2:end,:);
bosright{i,:} = frameBOS{i,1}(2:2:end,:);
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tosleft{i,1})
jointI(j) = tosleft{i,1}.JointI(j);
jointJ(j) = bosleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameBSS{i,1}.("Frame ID"));
frameDOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bosright{i,1})
jointI(j) = bosright{i,1}.JointI(j);
jointJ(j) = tosright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS1{i,1}.("Frame ID"));
frameDOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
frameDOS = cellfun(@(varargin)vertcat(varargin{:}),frameDOS1,frameDOS2,'UniformOutput',false);
%% Name the Frame
% diagonal special segment (DSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
tssright{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
bssright{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS{i,1}.("Frame ID"));
frameDSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bssright{i,1})
jointI(j) = bssright{i,1}.JointI(j);
jointJ(j) = tssright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDSS1{i,1}.("Frame ID"));
frameDSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
frameDSS = cellfun(@(varargin)vertcat(varargin{:}),frameDSS1,frameDSS2,'UniformOutput',false);
%% Name the Frame
% vertical special segment (VSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointI(j);
end
lastframenumber{i,:} = max(frameDSS{i,1}.("Frame ID"));
frameVSS{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)',jointI',jointJ','VariableNames',{'Frame ID','JointI','JointJ'});
end
%% Print 'frame' data to textline
txtframeCOLUMN = strings(height(framecolumn),1);
for i = 1:height(framecolumn)
T = framecolumn{i};
M = T{:,:};
txtframeCOLUMN(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeTOS = strings(height(frameTOS),1);
for i = 1:height(frameTOS)
T = frameTOS{i};
M = T{:,:};
txtframeTOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeBOS = strings(height(frameBOS),1);
for i = 1:height(frameBOS)
T = frameBOS{i};
M = T{:,:};
txtframeBOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeTSS = strings(height(frameTSS),1);
for i = 1:height(frameTSS)
T = frameTSS{i};
M = T{:,:};
txtframeTSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeBSS = strings(height(frameBSS),1);
for i = 1:height(frameBSS)
T = frameBSS{i};
M = T{:,:};
txtframeBSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeDOS = strings(height(frameDOS),1);
for i = 1:height(frameDOS)
T = frameDOS{i};
M = T{:,:};
txtframeDOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeDSS = strings(height(frameDSS),1);
for i = 1:height(frameDSS)
T = frameDSS{i};
M = T{:,:};
txtframeDSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
txtframeVSS = strings(height(frameVSS),1);
for i = 1:height(frameVSS)
T = frameVSS{i};
M = T{:,:};
txtframeVSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No \n",M.');
end
%% Print 'joint' data to textline
txtjointBASE = strings(height(jointbase),1);
for i = 1:height(jointbase)
T = jointbase.("Joint Base"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBASE(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
txtjointCOLUMN = strings(height(jointcolumn),1);
for i = 1:height(jointcolumn)
T = jointcolumn.("Joint Column"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointCOLUMN(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
txtjointTOS = strings(height(jointtopordinarysegment),1);
for i = 1:height(jointtopordinarysegment)
T = jointtopordinarysegment.("Joint Top Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
txtjointBOS = strings(height(jointbottomordinarysegment),1);
for i = 1:height(jointbottomordinarysegment)
T = jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
txtjointTSS = strings(height(jointtopspecialsegment),1);
for i = 1:height(jointtopspecialsegment)
T = jointtopspecialsegment.("Joint Top Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
txtjointBSS = strings(height(jointbottomspecialsegment),1);
for i = 1:height(jointbottomspecialsegment)
T = jointbottomspecialsegment.("Joint Bottom Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3f\n",M.');
end
%% WRITE s2k Extension Files
VariantModel = compose('%d', 1:height(VariantIDPassed));
lined= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
for i = 1:numel(VariantModel)
writefile(VariantModel{i},txtjointBASE{i},txtjointCOLUMN{i},txtjointTOS{i},txtjointBOS{i},txtjointTSS{i},txtjointBSS{i},txtframeCOLUMN{i},txtframeTOS{i},txtframeBOS{i},txtframeTSS{i},txtframeBSS{i},txtframeDOS{i},txtframeDSS{i},txtframeVSS{i});
end
files = dir('*.s2k');
files(:).name;
function writefile(C,txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS,txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS)
fido = fopen("ModelVariant"+C+".s2k",'wt');
newline = '\n';
line1='File D:\MAGISTER\KULIAH\TESIS\S2K FILE\ModelVariant-%d.s2k was saved on m/d/yy at h:mm:ss';
line2='TABLE: "PROGRAM CONTROL"';
line3=' ProgramName=SAP2000 Version=25.0.0 ProgLevel=Ultimate LicenseNum=3010*1D6KZBK478DMQCT LicenseOS=Yes LicenseSC=Yes LicenseHT=No CurrUnits="KN, m, C" SteelCode="AISC 360-10" ConcCode="ACI 318-19" AlumCode="AA 2015" _';
line4=' ColdCode=AISI-16 RegenHinge=Yes';
line5='TABLE: "ACTIVE DEGREES OF FREEDOM"';
line6=' UX=Yes UY=No UZ=Yes RX=No RY=Yes RZ=No';
line7='TABLE: "ANALYSIS OPTIONS"';
line8=' Solver=Multithreaded SolverProc="Analysis Process" NumParallel=0 Force32Bit=No StiffCase=None GeomMod=None HingeOpt="In Elements" NumAThreads=0 MaxFileSize=0 NumDThreads=0 NumRThreads=0 _ UseMMFiles="Program Determined" AllowDiff=No';
line9='TABLE: "COORDINATE SYSTEMS"';
line10=' Name=GLOBAL Type=Cartesian X=0 Y=0 Z=0 AboutZ=0 AboutY=0 AboutX=0';
line11='TABLE: "GRID LINES"';
line12=' CoordSys=GLOBAL AxisDir=X GridID=A XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End AllVisible=Yes BubbleSize=1,5';
line13=' CoordSys=GLOBAL AxisDir=X GridID=B XRYZCoord=15 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End';
line14=' CoordSys=GLOBAL AxisDir=X GridID=C XRYZCoord=30 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End';
line15=' CoordSys=GLOBAL AxisDir=Y GridID=1 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=Start';
line16=' CoordSys=GLOBAL AxisDir=Z GridID=Z0 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End';
line17=' CoordSys=GLOBAL AxisDir=Z GridID=Z1 XRYZCoord=5 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End';
line18=' CoordSys=GLOBAL AxisDir=Z GridID=Z2 XRYZCoord=10 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End';
line19='TABLE: "MATERIAL PROPERTIES 01 - GENERAL"';
line20=' Material=4000Psi Type=Concrete Grade="' + "f'c 4000 " + 'psi"'+ ' SymType=Isotropic TempDepend=No Color=Green GUID=b0920fc0-a39b-46e4-a096-037f0f0739a7 Notes="Customary '+"f'c 4000 psi "+'01/02/2024 20:13:33"';
line21=' Material=BJ-37 Type=Steel Grade="Grade 50" SymType=Isotropic TempDepend=No Color=Magenta Notes="ASTM A992 Grade 50 01/02/2024 20:03:34"';
line22='TABLE: "MATERIAL PROPERTIES 02 - BASIC MECHANICAL PROPERTIES"';
line23=' Material=4000Psi UnitWeight=23,5631216161854 UnitMass=2,40276960558926 E1=24855578,0600518 G12=10356490,8583549 U12=0,2 A1=9,89999952793124E-06';
line24=' Material=BJ-37 UnitWeight=76,9728639422648 UnitMass=7,84904737995992 E1=199947978,795958 G12=76903068,7676762 U12=0,3 A1=1,16999994421006E-05';
line25='TABLE: "MATERIAL PROPERTIES 03A - STEEL DATA"';
line26=' Material=BJ-37 Fy=235000 Fu=352500 EffFy=235000 EffFu=352500 SSCurveOpt=Simple SSHysType=Kinematic SHard=0,015 SMax=0,11 SRup=0,17 FinalSlope=-0,1 CoupModType="Von Mises"';
line27='TABLE: "MATERIAL PROPERTIES 06 - DAMPING PARAMETERS"';
line28=' Material=4000Psi ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0';
line29=' Material=BJ-37 ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0';
line30='TABLE: "MATERIAL PROPERTIES 09 - ACCEPTANCE CRITERIA"';
line31=' Material=4000Psi IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,003 LSComp=-0,006 CPComp=-0,015 IgnoreTens=Yes';
line32=' Material=BJ-37 IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,005 LSComp=-0,01 CPComp=-0,02';
line33='TABLE: "FRAME SECTION PROPERTIES 01 - GENERAL"';
line34=' SectionName=ExampleWideFlanged Material=BJ-37 Shape="I/Wide Flange" t3=0,25 t2=0,15 tf=0,012 tw=0,008 t2b=0,15 tfb=0,012 FilletRadius=0,012 Area=0,005552 TorsConst=2,13418666666667E-07 I33=6,04638656154112E-05 _';
line35=' I22=6,76749435145855E-06 I23=-6,7762635780344E-21 AS2=0,00200790111881035 AS3=0,00357344416053972 S33Top=0,00048371092492329 S33Bot=0,00048371092492329 S22Left=9,02332580194473E-05 S22Right=9,02332580194473E-05 _';
line36=' Z33=0,000546402338734841 Z22=0,00013961366126516 R33=0,10435739412628 R22=0,0349131651083826 CGOffset3=-1,38777878078145E-17 CGOffset2=5,55111512312578E-17 EccV2=0 EccV3=0 Cw=9,558675E-08 ConcCol=No ConcBeam=No _';
line37=' Color=Blue TotalWt=60,3707599671425 TotalMass=6,15610399662034 FromFile=No AMod=1 A2Mod=1 A3Mod=1 JMod=1 I2Mod=1 I3Mod=1 MMod=1 WMod=1 Notes="Added 03/04/2024 20:08:55';
line38='TABLE: "LOAD PATTERN DEFINITIONS"';
line39=' LoadPat=DEAD DesignType=Dead SelfWtMult=1 GUID=d2c74fc0-a771-416d-b3dc-4b0a2047268d';
line40=' LoadPat=SUPERDEAD DesignType="Super Dead" SelfWtMult=0 GUID=91534b51-672f-4fb0-a037-d7225de00c69 Notes="Added 01/02/2024 20:08:11"';
line41=' LoadPat=LIVE DesignType=Live SelfWtMult=0 GUID=1f6f6fd1-e0f1-4fcb-bf3d-dc86bd53f1a8 Notes="Added 01/02/2024 20:08:16"';
line42='TABLE: "GROUPS 1 - DEFINITIONS"';
line43=' GroupName=All Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red';
line44=' GroupName=ST_Top Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark';
line45=' GroupName=ST_Bot Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue';
line46=' GroupName=ST_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green';
line47=' GroupName=ST_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan';
line48=' GroupName=OT_Top1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red';
line49=' GroupName=OT_Top2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Yellow';
line49a=' GroupName=OT_Bot1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark';
line49b=' GroupName=OT_Bot2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue';
line49c=' GroupName=OT_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green';
line49d=' GroupName=OT_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan';
line49e=' GroupName=Column_End Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red';
line50='TABLE: "JOINT PATTERN DEFINITIONS"';
line51=' Pattern=Default';
line52='TABLE: "MASS SOURCE"';
line53=' MassSource=MSSSRC1 Elements=Yes Masses=Yes Loads=Yes IsDefault=Yes LoadPat=DEAD Multiplier=1';
line54=' MassSource=MSSSRC1 LoadPat=SUPERDEAD Multiplier=1';
line55=' MassSource=MSSSRC1 LoadPat=LIVE Multiplier=0,5';
line56='TABLE: "LOAD CASE DEFINITIONS"';
line57=' Case=DEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=91b91585-f6e6-446e-ac30-362013fd8af9';
line58=' Case=MODAL Type=LinModal InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Other DesActOpt="Prog Det" DesignAct=Other AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=3e160405-efbf-45fb-ae06-c6da634ca183';
line59=' Case=SUPERDEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType="Super Dead" DesActOpt="Prog Det" DesignAct="Long-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=2ca565b7-af73-42e9-9208-0a0739594699';
line60=' Case=LIVE Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Live DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e969dd8f-56cc-40d7-af8a-0fba39157fcb';
line61=' Case="Gravity NLS" Type=NonStatic InitialCond=Zero MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae';
line62=' Case=Pushover-UX Type=NonStatic InitialCond="Gravity NLS" MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Quake DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae';
line63='TABLE: "CASE - STATIC 1 - LOAD ASSIGNMENTS"';
line64=' Case=DEAD LoadType="Load pattern" LoadName=DEAD LoadSF=1';
line65=' Case=SUPERDEAD LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1';
line66=' Case=LIVE LoadType="Load pattern" LoadName=LIVE LoadSF=1';
line67=' Case="Gravity NLS" LoadType="Load pattern" LoadName=DEAD LoadSF=1';
line68=' Case="Gravity NLS" LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1';
line69=' Case="Gravity NLS" LoadType="Load pattern" LoadName=LIVE LoadSF=0,5';
line70=' Case=Pushover-UX LoadType=Accel LoadName="Accel UX" TransAccSF=-1';
line71='TABLE: "CASE - STATIC 2 - NONLINEAR LOAD APPLICATION"';
line72=' Case="Gravity NLS" LoadApp="Full Load" MonitorDOF=U1 MonitorJt=9';
line73=' Case=Pushover-UX LoadApp="Displ Ctrl" DisplType=Monitored TargetDispl=1 MonitorDOF=U1 MonitorJt=9';
line74='TABLE: "CASE - STATIC 4 - NONLINEAR PARAMETERS"';
line75=' Case="Gravity NLS" GeoNonLin=P-Delta ResultsSave="Final State" SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 _';
line76=' TFAccelFact=1 TFNoStop=No';
line77=' Case=Pushover-UX GeoNonLin=P-Delta ResultsSave="Multiple States" MinNumState=10 MaxNumState=100 PosIncOnly=Yes SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 _';
line78=' MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 TFAccelFact=1 TFNoStop=No';
line79='TABLE: "CASE - MODAL 1 - GENERAL"';
line80=' Case=MODAL ModeType=Eigen MaxNumModes=12 MinNumModes=1 EigenShift=0 EigenCutoff=0 EigenTol=1E-09 AutoShift=Yes';
line81='TABLE: "JOINT COORDINATES"';
line82= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
line83='TABLE: "CONNECTIVITY - FRAME"';
line84= append(txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS);
line85='TABLE: "END TABLE DATA"';
combine1 = append(line1,newline,line2,newline,line3,newline,line4,newline,line5,newline,line6,newline,line7,newline,line8,newline,line9,newline,line10,newline,line11,newline,line12,newline,line13,newline,line14,newline,line15,newline,line16,newline,line17,newline,line18,newline,line19,newline,line20,newline,line21,newline,line22,newline,line23,newline,line24,newline,line25,newline,line26,newline,line27,newline,line28,newline,line29,newline,line30,newline,line31,newline,line32,newline,line33,newline,line34,newline,line35,newline,line36);
combine2 = append(combine1,newline,line37,newline,line38,newline,line39,newline,line40,newline,line41,newline,line42,newline,line43,newline,line44,newline,line45,newline,line46,newline,line47,newline,line48,newline,line49,newline,line49a,newline,line49b,newline,line49c,newline,line49d,newline,line49e,newline,line50,newline,line51,newline,line52,newline,line53,newline,line54,newline,line55,newline,line56,newline,line57,newline,line58,newline,line59,newline,line60,newline,line61,newline,line62,newline,line63,newline,line64,newline,line65,newline,line66,newline,line67,newline,line68,newline);
combine3 = append(combine2,line69,newline,line70,newline,line71,newline,line72,newline,line73,newline,line74,newline,line75,newline,line76,newline,line77,newline,line78,newline,line79,newline,line80,newline,line81,newline,line82,newline,line83,newline,line84,newline,line85);
fprintf(fido,combine3,C);
fclose(fido);
end
0 commentaires
Réponse acceptée
Anton Kogios
le 28 Avr 2024
Modifié(e) : Anton Kogios
le 28 Avr 2024
'\' is a formatting operator, so to get a backslash using fprintf/sprintf, you need to have a '\\'. Your first line contains multiple backslashes, the first of which is '\M', hence the warning. MATLAB thinks you are specifying '\M' as a format specifier, which doesn't exist.
Did you check the documentation like the warning told you? See below for the relevant section:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1681016/image.png)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Computations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!