how to show live return of variable in command windows while running a looping.

5 ビュー (過去 30 日間)
Arif
Arif 2024 年 5 月 13 日
回答済み: Joe Vinciguerra 2024 年 5 月 13 日
hi guys im running script in looping for 8901 ii in array. But my command windows and workspace not update and show the live return of variables. I want to know everytime the ''ii'' value.
here i attached my code :
%% clean-up the workspace & command window
clear;
clc;
tic;
%% Preparation to connect with OAPI SAP2000
%set the following flag to true to attach to an existing instance of the program otherwise a new instance of the program will be started
AttachToInstance = true();
% set the following flag to true to manually specify the path to ETABS.exe
% this allows for a connection to a version of ETABS other than the latest installation
% otherwise the latest installed version of ETABS will be launched
SpecifyPath = true();
% if the above flag is set to true, specify the path to ETABS below
ProgramPath = 'C:\Program Files\Computers and Structures\SAP2000 25\SAP2000.exe';
% full path to API dll set it to the installation folder
APIDLLPath = 'C:\Program Files\Computers and Structures\SAP2000 25\SAP2000v1.dll';
% create API helper objectETABSv1ETAB
a = NET.addAssembly(APIDLLPath);
helper = SAP2000v1.Helper;
helper = NET.explicitCast(helper,'SAP2000v1.cHelper');
if AttachToInstance
% attach to a running instance of ETABS
SapObject = helper.GetObject('CSI.SAP2000.API.SapObject');
SapObject = NET.explicitCast(SapObject,'SAP2000v1.cOAPI');
else
if SpecifyPath
% create an instance of the ETABS object from the specified path
SapObject = helper.CreateObject(ProgramPath);
else
% create an instance of the ETABS object from the latest installed ETABS
SapObject = helper.CreateObjectProgID('CSI.SAP2000.API.SapObject');
end
SapObject = NET.explicitCast(SapObject,'SAP2000v1.cOAPI');
% start ETABS application
SapObject.ApplicationStart;
end
helper = 0;
% create SapModel object
SapModel = NET.explicitCast(SapObject.SapModel,'SAP2000v1.cSapModel');
%% Define Variant Model
VariantModel = compose('%d',2:2);
VariantENDT= compose('A%d',1:5);
VariantTOS1= compose('A%d',1:3);
VariantTOS2 = compose('B%d',1:3);
VariantTOS3 = compose('B%d',1:3);
VariantBOS1 = compose('C%d',1:3);
VariantBOS2 = compose('D%d',1:3);
VariantBOS3 = compose('D%d',1:3);
VariantDOS1 = compose('E%d',1:3);
VariantDOS2 = compose('F%d',1:3);
VariantVOS = compose('G%d',1:1);
VariantTSS = compose('H%d',1:4);
VariantBSS = compose('I%d',1:4);
VariantDSS = compose('J%d',1:1);
VariantVSS = compose('K%d',1:1);
VariantCOL = compose('L%d',1:4);
%% Define Variable For Looping Analysis
Specimen = repmat("",length(VariantModel)*length(VariantENDT)*length(VariantTOS1)*length(VariantBOS1)*length(VariantDOS1)*length(VariantVOS)*length(VariantTSS)*length(VariantBSS)*length(VariantDSS)*length(VariantCOL),1);
Optimizevalue = zeros(1,length(Specimen));
checkratio = strings(1,length(Specimen));
CheckHingeCOL = strings(1,length(Specimen));
checkfuse = strings(1,length(Specimen));
R = zeros(1,length(Specimen));
W = zeros(1,length(Specimen));
Cg = zeros(1,length(Specimen));
ii = 0;
for i = 1:length(Specimen)
for iVAR = 1:length(VariantModel)
for iEND = 1:length(VariantENDT)
ENDsection = string(VariantENDT(iEND));
for iTOS = 1:length(VariantTOS1)
TOS1section = string(VariantTOS1(iTOS));
TOS2section = string(VariantTOS2(iTOS));
TOS3section = string(VariantTOS3(iTOS));
for iBOS = 1 : length(VariantBOS1)
BOS1section = string(VariantBOS1(iBOS));
BOS2section = string(VariantBOS2(iBOS));
BOS3section = string(VariantBOS3(iBOS));
for iDOS = 1 : length(VariantDOS1)
DOS1section = string(VariantDOS1(iDOS));
DOS2section = string(VariantDOS2(iDOS));
for iVOS = 1 : length(VariantVOS)
VOSsection = string(VariantVOS(iVOS));
for iTSS = 1 : length(VariantTSS)
TSSsection = string(VariantTSS(iTSS));
for iBSS = 1 : length(VariantBSS)
BSSsection = string(VariantBSS(iBSS));
for iDSSVSS = 1 : length(VariantDSS)
DSSsection = string(VariantDSS(iDSSVSS));
VSSsection = string(VariantVSS(iDSSVSS));
for iCOL = 1 : length(VariantCOL)
COLsection = string(VariantCOL(iCOL));
ii = ii+1;
Specimen(ii) = append(VariantModel(iVAR),VariantENDT(iEND),VariantTOS1(iTOS),VariantTOS2(iTOS),VariantTOS3(iTOS),VariantBOS1(iBOS),VariantBOS2(iBOS),VariantBOS3(iBOS),VariantDOS1(iDOS),VariantDOS2(iDOS),VariantVOS(iVOS),VariantTSS(iTSS),VariantBSS(iBSS),VariantDSS(iDSSVSS),VariantVSS(iDSSVSS),VariantCOL(iCOL));
%% DEFINE OAPI FUNCTION
ret = SapModel.InitializeNewModel(SAP2000v1.eUnits.kN_m_C);
File = NET.explicitCast(SapModel.File,'SAP2000v1.cFile');
PropFrame = NET.explicitCast(SapModel.PropFrame,'SAP2000v1.cPropFrame');
Group=NET.explicitCast(SapModel.GroupDef,'SAP2000v1.cGroup');
FrameObj = NET.explicitCast(SapModel.FrameObj,'SAP2000v1.cFrameObj');
Analyze = NET.explicitCast(SapModel.Analyze,'SAP2000v1.cAnalyze');
DesignSteel = NET.explicitCast(SapModel.DesignSteel,'SAP2000v1.cDesignSteel');
View = NET.explicitCast(SapModel.View,'SAP2000v1.cView');
DatabaseTables = NET.explicitCast(SapModel.DatabaseTables,'SAP2000v1.cDatabaseTables');
SelectObj = NET.explicitCast(SapModel.SelectObj,'SAP2000v1.cSelect');
%% MODELING SAP2000
FileName = 'D:\\MAGISTER\\KULIAH\\TESIS\\MATLAB_PROCESSING MODEL\\Preliminary Section\\Prelimnarysection.s2k';
ret = File.OpenFile(FileName);
ret = SapModel.SetPresentUnits(SAP2000v1.eUnits.N_mm_C);
% define frame section property for A(EndTruss)
ret = PropFrame.SetTube('A1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('A2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('A3','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('A4','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('A5','BJ-37',304,304,12.7,12.7);
% define frame section property for B(TOS1)
ret = PropFrame.SetTube('B1','BJ-37',152,152,7.9,7.9);
ret = PropFrame.SetTube('B2','BJ-37',177,177,9.5,9.5);
ret = PropFrame.SetTube('B3','BJ-37',203,203,12.7,12.7);
% define frame section property for C(TOS2)
ret = PropFrame.SetTube('C1','BJ-37',177,177,9.5,9.5);
ret = PropFrame.SetTube('C2','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('C3','BJ-37',254,254,12.7,12.7);
% define frame section property for D(TOS3)
ret = PropFrame.SetTube('D1','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('D2','BJ-37',254,254,12.7,12.7);
ret = PropFrame.SetTube('D3','BJ-37',304,304,12.7,12.7);
% define frame section property for E(BOS1)
ret = PropFrame.SetTube('E1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('E2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('B3','BJ-37',203,203,7.9,7.9);
% define frame section property for F(BOS2)
ret = PropFrame.SetTube('F1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('F2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('F3','BJ-37',254,254,9.5,9.5);
% define frame section property for G(BOS3)
ret = PropFrame.SetTube('G1','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('G2','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('G3','BJ-37',304,304,12.7,12.7);
% define frame section property for H(DOS1)
ret = PropFrame.SetTube('H1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('H2','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('H3','BJ-37',254,254,12.7,12.7);
% define frame section property for I(DOS2)
ret = PropFrame.SetTube('I1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('I2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('I3','BJ-37',203,203,12.7,12.7);
% define frame section property for J(VOS)
ret = PropFrame.SetTube('J1','BJ-37',50,50,2.2,2.2);
% define frame section property for K(TSS)
ret = PropFrame.SetTube('K1','BJ-37',152,152,6.5,6.5);
ret = PropFrame.SetTube('K2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('K3','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('K4','BJ-37',254,254,12.7,12.7);
% define frame section property for L(BSS)
ret = PropFrame.SetTube('L1','BJ-37',152,152,4.8,4.8);
ret = PropFrame.SetTube('L2','BJ-37',177,177,6.5,6.5);
ret = PropFrame.SetTube('L3','BJ-37',203,203,7.9,7.9);
ret = PropFrame.SetTube('L4','BJ-37',254,254,9.5,9.5);
% define frame section property for M(DSS)
ret = PropFrame.SetTube('M1','BJ-37',40,40,2.2,2.2);
% define frame section property for N(VSS)
ret = PropFrame.SetTube('N1','BJ-37',30,30,2.2,2.2);
% define frame section property for O(COL)
ret = PropFrame.SetTube('O1','BJ-37',406,203,15.9,15.9);
ret = PropFrame.SetTube('O2','BJ-37',406,304,15.9,15.9);
ret = PropFrame.SetTube('O3','BJ-37',455,152,15.9,15.9);
ret = PropFrame.SetTube('O4','BJ-37',508,203,15.9,15.9);
% assign frame section by group
ret = FrameObj.SetSection('End Truss',ENDsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment1',TOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment2',TOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment3',TOS3section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment1',BOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment2',BOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment3',BOS3section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalOrdinarySegment1',DOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalOrdinarySegment2',DOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('VerticalOrdinarySegment',VOSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopSpecialSegment',TSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomSpecialSegment',BSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalSpecialSegment',DSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('VerticalSpecialSegment',VSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('Column',COLsection,SAP2000v1.eItemType.Group);
%% running analyze
ret = File.Save('D:\\MAGISTER\\KULIAH\\TESIS\\MATLAB_PROCESSING MODEL\\Preliminary Section\\RUNNING SAP\\Preliminarysection-'+string(Specimen(ii)));
ret = SapModel.SetPresentUnits(SAP2000v1.eUnits.kN_m_C);
ret = Analyze.RunAnalysis();
%% check design steel section
% Add load combination
RespCombo = NET.explicitCast(SapModel.RespCombo,'SAP2000v1.cCombo');
ret = RespCombo.Add('1.2D+1.6L',0);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'DEAD',1.2);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'SUPERDEAD',1.2);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'LIVE',1.6);
% DesignSteel
ret = DesignSteel.SetCode('AISC 360-10');
ret = DesignSteel.SetComboStrength('1.2D+1.6L',true);
ret = DesignSteel.SetComboAutoGenerate(false);
ret = DesignSteel.StartDesign();
ret = View.RefreshView(0, false());
%% set load case and combo for display table
LoadCaseList = NET.createArray('System.String',6);
LoadCaseList(1)='DEAD';
LoadCaseList(2)='MODAL';
LoadCaseList(3)='SUPERDEAD';
LoadCaseList(4)='LIVE';
LoadCaseList(5)='Gravity NLS';
LoadCaseList(6)='Pushover-UX';
ret = DatabaseTables.SetLoadCasesSelectedForDisplay({'MODAL','DEAD','SUPERDEAD','LIVE','Gravity NLS','Pushover-UX'});
LoadCombList = NET.createArray('System.String',1);
LoadCombList(1)='1.2D+1.6L';
ret = DatabaseTables.SetLoadCombinationsSelectedForDisplay({'1.2D+1.6L'});
ret = DatabaseTables.SetTableOutputOptionsForDisplay(0,0,0,true,1,12,true,1,12,2,2,2,2,2,3,1,1,2);
%% get frame label
NumberFrame = 0;
AllFrameName = {''};
[~,NumberFrame,AllFrameName] = FrameObj.GetNameList(NumberFrame,AllFrameName);
% Column
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("Column");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameCOL = string(ObjectName);
% Endtruss
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("End Truss");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameEND = string(ObjectName);
% Top Ordinary Segment (TOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("TopOrdinarySegment1");
ret = SelectObj.Group("TopOrdinarySegment2");
ret = SelectObj.Group("TopOrdinarySegment3");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameTOS = string(ObjectName);
% Bottom Ordinary Segment (BOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("BottomOrdinarySegment1");
ret = SelectObj.Group("BottomOrdinarySegment2");
ret = SelectObj.Group("BottomOrdinarySegment3");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameBOS = string(ObjectName);
% Diagonal Ordinary Segment (DOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("DiagonalOrdinarySegment1");
ret = SelectObj.Group("DiagonalOrdinarySegment2");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameDOS = string(ObjectName);
% Diagonal Ordinary Segment (VOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("VeticalOrdinarySegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameVOS = string(ObjectName);
% Top Special Segment (TSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("TopSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameTSS = string(ObjectName);
% Bottom Special Segment (BSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("BottomSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameBSS = string(ObjectName);
% Diagonal Special Segment (DSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("DiagonalSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameDSS = string(ObjectName);
% Vertical Special Segment (VSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("VerticalSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameVSS = string(ObjectName);
%% get alltable
NumberTables = 0;
TableKey = {''};
TableName = {''};
ImportType = 0;
IsEmpty = NET.createArray('System.Boolean',NumberTables);
[ret,NumberTables,TableKey,TableName,ImportType,IsEmpty] = DatabaseTables.GetAllTables(NumberTables,TableKey,TableName,ImportType,IsEmpty);
TableKey = string(TableKey)';
TableName = string(TableName)';
ImportType = int32(ImportType)';
IsEmpty = logical(IsEmpty)';
TableKey = array2table(TableKey,"VariableNames",{'TableKey'});
TableName = array2table(TableName,"VariableNames",{'TableName'});
ImportType = array2table(ImportType,"VariableNames",{'ImportType'});
IsEmpty = array2table(IsEmpty,"VariableNames",{'IsEmpty'});
%Daftartabel = table(TableKey,TableName,ImportType,IsEmpty);
%Daftartabel = table2array(Daftartabel);
%% period of structure
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Modal Periods And Frequencies",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
Period{ii,:} = array2table(TableData,"VariableNames",FieldKeysIncluded);
%% Steel Design Check
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Steel Design 1 - Summary Data - AISC 360-10",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
steeldesignresult = array2table(TableData,"VariableNames",FieldKeysIncluded);
% check maximum ratio
ratio = steeldesignresult.Ratio(:);
ratio = strrep(ratio,',','.');
ratio = str2double(ratio);
maximumratio = sort(ratio,'descend');
maximumratio = maximumratio(1);
ratiolimit = 1.00;
if maximumratio<ratiolimit
checkratio(ii) = 'Ratio OK';
else
checkratio(ii) = 'Ratio exceeds allowable limit';
end
ratioCOL{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameCOL));
ratioEND{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameEND));
ratioTOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameTOS));
ratioBOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameBOS));
ratioDOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameDOS));
ratioVOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameVOS));
ratioTSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameTSS));
ratioBSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameBSS));
ratioDSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameDSS));
ratioVSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameVSS));
%% pushover result
% base-shear
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Base Reactions",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
basereaction = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter1 = strcmp(basereaction.OutputCase,'Pushover-UX');
baseshearpushx = basereaction(filter1,{'StepNum','GlobalFX','GlobalFZ'});
% display displacement of monitored point
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Joint Displacements",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
jointdisplacement = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter1 = strcmp(jointdisplacement.Joint,'4');
tableout1 = jointdisplacement(filter1,{'OutputCase','StepNum','U1'});
filter2 = strcmp(tableout1.OutputCase,'Pushover-UX');
point5disp = tableout1(filter2,{'StepNum','U1'});
% pushover table
pushovertable{ii,:} = join(baseshearpushx,point5disp);
plotx = str2double(strrep(pushovertable{ii,1}.U1,',','.'));
ploty = str2double(strrep(pushovertable{ii,1}.GlobalFX,',','.'));
%plot(plotx,ploty);
%xlabel('Displacement(m)');
%ylabel('Base Shear(kN)');
%grid on;
%% display hinge states
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Frame Hinge States",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
hingeresult{ii,:} = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameCOL);
hingeCOL = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameEND);
hingeEND = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameTOS);
%hingeTOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameBOS);
%hingeBOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameDOS);
%hingeDOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameVOS);
%hingeVOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameTSS);
hingeTSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameBSS);
hingeBSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameDSS);
%hingeDSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameVSS);
%hingeVSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%% check fuse first yielding
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.HingeState,{'B to C'});
firstyieldlist{ii,:} = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
stepfirstyield = firstyieldlist{ii,1}.StepNum(:);
stepfirstyield = str2double(stepfirstyield);
stepfirstyield = sort(stepfirstyield,'ascend');
stepfirstyield = stepfirstyield(1);
stepfirstyield = int2str(stepfirstyield);
framefirstyield{ii,:} = firstyieldlist{ii,1}.Frame(strcmp(firstyieldlist{ii,1}.StepNum,stepfirstyield));
testfuse = ismember(framefirstyield{ii,1},[frameTSS,frameBSS]);
if testfuse == any(true)
checkfuse(ii) = 'Fuse Correct';
else
checkfuse(ii) = 'Fuse wrong designed';
end
end
end
end
end
end
end
end
end
end
end
end
toc
runningtime = toc;
  3 件のコメント
Arif
Arif 2024 年 5 月 13 日
align like this ?
%% clean-up the workspace & command window
clear;
clc;
tic;
%% Preparation to connect with OAPI SAP2000
%set the following flag to true to attach to an existing instance of the program otherwise a new instance of the program will be started
AttachToInstance = true();
% set the following flag to true to manually specify the path to ETABS.exe
% this allows for a connection to a version of ETABS other than the latest installation
% otherwise the latest installed version of ETABS will be launched
SpecifyPath = true();
% if the above flag is set to true, specify the path to ETABS below
ProgramPath = 'C:\Program Files\Computers and Structures\SAP2000 25\SAP2000.exe';
% full path to API dll set it to the installation folder
APIDLLPath = 'C:\Program Files\Computers and Structures\SAP2000 25\SAP2000v1.dll';
% create API helper objectETABSv1ETAB
a = NET.addAssembly(APIDLLPath);
helper = SAP2000v1.Helper;
helper = NET.explicitCast(helper,'SAP2000v1.cHelper');
if AttachToInstance
% attach to a running instance of ETABS
SapObject = helper.GetObject('CSI.SAP2000.API.SapObject');
SapObject = NET.explicitCast(SapObject,'SAP2000v1.cOAPI');
else
if SpecifyPath
% create an instance of the ETABS object from the specified path
SapObject = helper.CreateObject(ProgramPath);
else
% create an instance of the ETABS object from the latest installed ETABS
SapObject = helper.CreateObjectProgID('CSI.SAP2000.API.SapObject');
end
SapObject = NET.explicitCast(SapObject,'SAP2000v1.cOAPI');
% start ETABS application
SapObject.ApplicationStart;
end
helper = 0;
% create SapModel object
SapModel = NET.explicitCast(SapObject.SapModel,'SAP2000v1.cSapModel');
%% Define Variant Model
VariantModel = compose('%d',2:2);
VariantENDT= compose('A%d',1:5);
VariantTOS1= compose('A%d',1:3);
VariantTOS2 = compose('B%d',1:3);
VariantTOS3 = compose('B%d',1:3);
VariantBOS1 = compose('C%d',1:3);
VariantBOS2 = compose('D%d',1:3);
VariantBOS3 = compose('D%d',1:3);
VariantDOS1 = compose('E%d',1:3);
VariantDOS2 = compose('F%d',1:3);
VariantVOS = compose('G%d',1:1);
VariantTSS = compose('H%d',1:4);
VariantBSS = compose('I%d',1:4);
VariantDSS = compose('J%d',1:1);
VariantVSS = compose('K%d',1:1);
VariantCOL = compose('L%d',1:4);
%% Define Variable For Looping Analysis
Specimen = repmat("",length(VariantModel)*length(VariantENDT)*length(VariantTOS1)*length(VariantBOS1)*length(VariantDOS1)*length(VariantVOS)*length(VariantTSS)*length(VariantBSS)*length(VariantDSS)*length(VariantCOL),1);
Optimizevalue = zeros(1,length(Specimen));
checkratio = strings(1,length(Specimen));
CheckHingeCOL = strings(1,length(Specimen));
checkfuse = strings(1,length(Specimen));
R = zeros(1,length(Specimen));
W = zeros(1,length(Specimen));
Cg = zeros(1,length(Specimen));
ii = 0;
for i = 1:length(Specimen)
for iVAR = 1:length(VariantModel)
for iEND = 1:length(VariantENDT)
ENDsection = string(VariantENDT(iEND));
for iTOS = 1:length(VariantTOS1)
TOS1section = string(VariantTOS1(iTOS));
TOS2section = string(VariantTOS2(iTOS));
TOS3section = string(VariantTOS3(iTOS));
for iBOS = 1 : length(VariantBOS1)
BOS1section = string(VariantBOS1(iBOS));
BOS2section = string(VariantBOS2(iBOS));
BOS3section = string(VariantBOS3(iBOS));
for iDOS = 1 : length(VariantDOS1)
DOS1section = string(VariantDOS1(iDOS));
DOS2section = string(VariantDOS2(iDOS));
for iVOS = 1 : length(VariantVOS)
VOSsection = string(VariantVOS(iVOS));
for iTSS = 1 : length(VariantTSS)
TSSsection = string(VariantTSS(iTSS));
for iBSS = 1 : length(VariantBSS)
BSSsection = string(VariantBSS(iBSS));
for iDSSVSS = 1 : length(VariantDSS)
DSSsection = string(VariantDSS(iDSSVSS));
VSSsection = string(VariantVSS(iDSSVSS));
for iCOL = 1 : length(VariantCOL)
COLsection = string(VariantCOL(iCOL));
ii = ii+1;
Specimen(ii) = append(VariantModel(iVAR),VariantENDT(iEND),VariantTOS1(iTOS),VariantTOS2(iTOS),VariantTOS3(iTOS),VariantBOS1(iBOS),VariantBOS2(iBOS),VariantBOS3(iBOS),VariantDOS1(iDOS),VariantDOS2(iDOS),VariantVOS(iVOS),VariantTSS(iTSS),VariantBSS(iBSS),VariantDSS(iDSSVSS),VariantVSS(iDSSVSS),VariantCOL(iCOL));
%% DEFINE OAPI FUNCTION
ret = SapModel.InitializeNewModel(SAP2000v1.eUnits.kN_m_C);
File = NET.explicitCast(SapModel.File,'SAP2000v1.cFile');
PropFrame = NET.explicitCast(SapModel.PropFrame,'SAP2000v1.cPropFrame');
Group=NET.explicitCast(SapModel.GroupDef,'SAP2000v1.cGroup');
FrameObj = NET.explicitCast(SapModel.FrameObj,'SAP2000v1.cFrameObj');
Analyze = NET.explicitCast(SapModel.Analyze,'SAP2000v1.cAnalyze');
DesignSteel = NET.explicitCast(SapModel.DesignSteel,'SAP2000v1.cDesignSteel');
View = NET.explicitCast(SapModel.View,'SAP2000v1.cView');
DatabaseTables = NET.explicitCast(SapModel.DatabaseTables,'SAP2000v1.cDatabaseTables');
SelectObj = NET.explicitCast(SapModel.SelectObj,'SAP2000v1.cSelect');
%% MODELING SAP2000
FileName = 'D:\\MAGISTER\\KULIAH\\TESIS\\MATLAB_PROCESSING MODEL\\Preliminary Section\\Prelimnarysection.s2k';
ret = File.OpenFile(FileName);
ret = SapModel.SetPresentUnits(SAP2000v1.eUnits.N_mm_C);
% define frame section property for A(EndTruss)
ret = PropFrame.SetTube('A1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('A2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('A3','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('A4','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('A5','BJ-37',304,304,12.7,12.7);
% define frame section property for B(TOS1)
ret = PropFrame.SetTube('B1','BJ-37',152,152,7.9,7.9);
ret = PropFrame.SetTube('B2','BJ-37',177,177,9.5,9.5);
ret = PropFrame.SetTube('B3','BJ-37',203,203,12.7,12.7);
% define frame section property for C(TOS2)
ret = PropFrame.SetTube('C1','BJ-37',177,177,9.5,9.5);
ret = PropFrame.SetTube('C2','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('C3','BJ-37',254,254,12.7,12.7);
% define frame section property for D(TOS3)
ret = PropFrame.SetTube('D1','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('D2','BJ-37',254,254,12.7,12.7);
ret = PropFrame.SetTube('D3','BJ-37',304,304,12.7,12.7);
% define frame section property for E(BOS1)
ret = PropFrame.SetTube('E1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('E2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('B3','BJ-37',203,203,7.9,7.9);
% define frame section property for F(BOS2)
ret = PropFrame.SetTube('F1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('F2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('F3','BJ-37',254,254,9.5,9.5);
% define frame section property for G(BOS3)
ret = PropFrame.SetTube('G1','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('G2','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('G3','BJ-37',304,304,12.7,12.7);
% define frame section property for H(DOS1)
ret = PropFrame.SetTube('H1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('H2','BJ-37',203,203,12.7,12.7);
ret = PropFrame.SetTube('H3','BJ-37',254,254,12.7,12.7);
% define frame section property for I(DOS2)
ret = PropFrame.SetTube('I1','BJ-37',152,152,6.4,6.4);
ret = PropFrame.SetTube('I2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('I3','BJ-37',203,203,12.7,12.7);
% define frame section property for J(VOS)
ret = PropFrame.SetTube('J1','BJ-37',50,50,2.2,2.2);
% define frame section property for K(TSS)
ret = PropFrame.SetTube('K1','BJ-37',152,152,6.5,6.5);
ret = PropFrame.SetTube('K2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('K3','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('K4','BJ-37',254,254,12.7,12.7);
% define frame section property for L(BSS)
ret = PropFrame.SetTube('L1','BJ-37',152,152,4.8,4.8);
ret = PropFrame.SetTube('L2','BJ-37',177,177,6.5,6.5);
ret = PropFrame.SetTube('L3','BJ-37',203,203,7.9,7.9);
ret = PropFrame.SetTube('L4','BJ-37',254,254,9.5,9.5);
% define frame section property for M(DSS)
ret = PropFrame.SetTube('M1','BJ-37',40,40,2.2,2.2);
% define frame section property for N(VSS)
ret = PropFrame.SetTube('N1','BJ-37',30,30,2.2,2.2);
% define frame section property for O(COL)
ret = PropFrame.SetTube('O1','BJ-37',406,203,15.9,15.9);
ret = PropFrame.SetTube('O2','BJ-37',406,304,15.9,15.9);
ret = PropFrame.SetTube('O3','BJ-37',455,152,15.9,15.9);
ret = PropFrame.SetTube('O4','BJ-37',508,203,15.9,15.9);
% assign frame section by group
ret = FrameObj.SetSection('End Truss',ENDsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment1',TOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment2',TOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopOrdinarySegment3',TOS3section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment1',BOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment2',BOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomOrdinarySegment3',BOS3section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalOrdinarySegment1',DOS1section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalOrdinarySegment2',DOS2section,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('VerticalOrdinarySegment',VOSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('TopSpecialSegment',TSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('BottomSpecialSegment',BSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('DiagonalSpecialSegment',DSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('VerticalSpecialSegment',VSSsection,SAP2000v1.eItemType.Group);
ret = FrameObj.SetSection('Column',COLsection,SAP2000v1.eItemType.Group);
%% running analyze
ret = File.Save('D:\\MAGISTER\\KULIAH\\TESIS\\MATLAB_PROCESSING MODEL\\Preliminary Section\\RUNNING SAP\\Preliminarysection-'+string(Specimen(ii)));
ret = SapModel.SetPresentUnits(SAP2000v1.eUnits.kN_m_C);
ret = Analyze.RunAnalysis();
%% check design steel section
% Add load combination
RespCombo = NET.explicitCast(SapModel.RespCombo,'SAP2000v1.cCombo');
ret = RespCombo.Add('1.2D+1.6L',0);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'DEAD',1.2);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'SUPERDEAD',1.2);
ret = RespCombo.SetCaseList('1.2D+1.6L',SAP2000v1.eCNameType.LoadCase,'LIVE',1.6);
% DesignSteel
ret = DesignSteel.SetCode('AISC 360-10');
ret = DesignSteel.SetComboStrength('1.2D+1.6L',true);
ret = DesignSteel.SetComboAutoGenerate(false);
ret = DesignSteel.StartDesign();
ret = View.RefreshView(0, false());
%% set load case and combo for display table
LoadCaseList = NET.createArray('System.String',6);
LoadCaseList(1)='DEAD';
LoadCaseList(2)='MODAL';
LoadCaseList(3)='SUPERDEAD';
LoadCaseList(4)='LIVE';
LoadCaseList(5)='Gravity NLS';
LoadCaseList(6)='Pushover-UX';
ret = DatabaseTables.SetLoadCasesSelectedForDisplay({'MODAL','DEAD','SUPERDEAD','LIVE','Gravity NLS','Pushover-UX'});
LoadCombList = NET.createArray('System.String',1);
LoadCombList(1)='1.2D+1.6L';
ret = DatabaseTables.SetLoadCombinationsSelectedForDisplay({'1.2D+1.6L'});
ret = DatabaseTables.SetTableOutputOptionsForDisplay(0,0,0,true,1,12,true,1,12,2,2,2,2,2,3,1,1,2);
%% get frame label
NumberFrame = 0;
AllFrameName = {''};
[~,NumberFrame,AllFrameName] = FrameObj.GetNameList(NumberFrame,AllFrameName);
% Column
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("Column");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameCOL = string(ObjectName);
% Endtruss
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("End Truss");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameEND = string(ObjectName);
% Top Ordinary Segment (TOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("TopOrdinarySegment1");
ret = SelectObj.Group("TopOrdinarySegment2");
ret = SelectObj.Group("TopOrdinarySegment3");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameTOS = string(ObjectName);
% Bottom Ordinary Segment (BOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("BottomOrdinarySegment1");
ret = SelectObj.Group("BottomOrdinarySegment2");
ret = SelectObj.Group("BottomOrdinarySegment3");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameBOS = string(ObjectName);
% Diagonal Ordinary Segment (DOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("DiagonalOrdinarySegment1");
ret = SelectObj.Group("DiagonalOrdinarySegment2");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameDOS = string(ObjectName);
% Diagonal Ordinary Segment (VOS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("VeticalOrdinarySegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameVOS = string(ObjectName);
% Top Special Segment (TSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("TopSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameTSS = string(ObjectName);
% Bottom Special Segment (BSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("BottomSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameBSS = string(ObjectName);
% Diagonal Special Segment (DSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("DiagonalSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameDSS = string(ObjectName);
% Vertical Special Segment (VSS)
NumberItems=0;
ObjectType=0;
ObjectName={''};
ret = SelectObj.Group("VerticalSpecialSegment");
[~,NumberItems,ObjectType,ObjectName] = SelectObj.GetSelected(NumberItems,ObjectType,ObjectName);
ret = SelectObj.ClearSelection;
frameVSS = string(ObjectName);
%% get alltable
NumberTables = 0;
TableKey = {''};
TableName = {''};
ImportType = 0;
IsEmpty = NET.createArray('System.Boolean',NumberTables);
[ret,NumberTables,TableKey,TableName,ImportType,IsEmpty] = DatabaseTables.GetAllTables(NumberTables,TableKey,TableName,ImportType,IsEmpty);
TableKey = string(TableKey)';
TableName = string(TableName)';
ImportType = int32(ImportType)';
IsEmpty = logical(IsEmpty)';
TableKey = array2table(TableKey,"VariableNames",{'TableKey'});
TableName = array2table(TableName,"VariableNames",{'TableName'});
ImportType = array2table(ImportType,"VariableNames",{'ImportType'});
IsEmpty = array2table(IsEmpty,"VariableNames",{'IsEmpty'});
%Daftartabel = table(TableKey,TableName,ImportType,IsEmpty);
%Daftartabel = table2array(Daftartabel);
%% period of structure
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Modal Periods And Frequencies",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
Period{ii,:} = array2table(TableData,"VariableNames",FieldKeysIncluded);
%% Steel Design Check
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Steel Design 1 - Summary Data - AISC 360-10",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
steeldesignresult = array2table(TableData,"VariableNames",FieldKeysIncluded);
% check maximum ratio
ratio = steeldesignresult.Ratio(:);
ratio = strrep(ratio,',','.');
ratio = str2double(ratio);
maximumratio = sort(ratio,'descend');
maximumratio = maximumratio(1);
ratiolimit = 1.00;
if maximumratio<ratiolimit
checkratio(ii) = 'Ratio OK';
else
checkratio(ii) = 'Ratio exceeds allowable limit';
end
ratioCOL{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameCOL));
ratioEND{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameEND));
ratioTOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameTOS));
ratioBOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameBOS));
ratioDOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameDOS));
ratioVOS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameVOS));
ratioTSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameTSS));
ratioBSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameBSS));
ratioDSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameDSS));
ratioVSS{ii,:} = steeldesignresult.Ratio(ismember(steeldesignresult.Frame,frameVSS));
%% pushover result
% base-shear
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Base Reactions",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
basereaction = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter1 = strcmp(basereaction.OutputCase,'Pushover-UX');
baseshearpushx = basereaction(filter1,{'StepNum','GlobalFX','GlobalFZ'});
% display displacement of monitored point
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Joint Displacements",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
jointdisplacement = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter1 = strcmp(jointdisplacement.Joint,'4');
tableout1 = jointdisplacement(filter1,{'OutputCase','StepNum','U1'});
filter2 = strcmp(tableout1.OutputCase,'Pushover-UX');
point5disp = tableout1(filter2,{'StepNum','U1'});
% pushover table
pushovertable{ii,:} = join(baseshearpushx,point5disp);
plotx = str2double(strrep(pushovertable{ii,1}.U1,',','.'));
ploty = str2double(strrep(pushovertable{ii,1}.GlobalFX,',','.'));
%plot(plotx,ploty);
%xlabel('Displacement(m)');
%ylabel('Base Shear(kN)');
%grid on;
%% display hinge states
TableVersion = zeros('int32');
FieldKeyList = {''};
FieldKeysIncluded = {''};
NumberRecords = zeros('int32');
TableData = {''};
[ret,~,TableVersion,FieldKeysIncluded,NumberRecords,TableData] = DatabaseTables.GetTableForDisplayArray("Frame Hinge States",FieldKeyList,'All',TableVersion,FieldKeysIncluded,NumberRecords,TableData);
TableVersion = int32(TableVersion);
FieldKeysIncluded = string(FieldKeysIncluded);
[ret,c,r] = size(FieldKeysIncluded);
c = int32(c);
r = int32(r);
NumberRecords = int32(NumberRecords);
TableData = cell(TableData);
TableData = reshape(TableData,c,[])';
hingeresult{ii,:} = array2table(TableData,"VariableNames",FieldKeysIncluded);
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameCOL);
hingeCOL = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameEND);
hingeEND = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameTOS);
%hingeTOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameBOS);
%hingeBOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameDOS);
%hingeDOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameVOS);
%hingeVOS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameTSS);
hingeTSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameBSS);
hingeBSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameDSS);
%hingeDSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.Frame,frameVSS);
%hingeVSS = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
%% check fuse first yielding
filter = strcmp(hingeresult{ii,1}.OutputCase,'Pushover-UX') & ismember(hingeresult{ii,1}.HingeState,{'B to C'});
firstyieldlist{ii,:} = hingeresult{ii,1}(filter,{'Frame','OutputCase','StepNum','GenHinge','RelDist','M3','R3Plastic','HingeState','HingeStatus'});
stepfirstyield = firstyieldlist{ii,1}.StepNum(:);
stepfirstyield = str2double(stepfirstyield);
stepfirstyield = sort(stepfirstyield,'ascend');
stepfirstyield = stepfirstyield(1);
stepfirstyield = int2str(stepfirstyield);
framefirstyield{ii,:} = firstyieldlist{ii,1}.Frame(strcmp(firstyieldlist{ii,1}.StepNum,stepfirstyield));
testfuse = ismember(framefirstyield{ii,1},[frameTSS,frameBSS]);
if testfuse == any(true)
checkfuse(ii) = 'Fuse Correct';
else
checkfuse(ii) = 'Fuse wrong designed';
end
end
end
end
end
end
end
end
end
end
end
end
toc
runningtime = toc;
Stephen23
Stephen23 2024 年 5 月 13 日
編集済み: Stephen23 2024 年 5 月 13 日
"align like this ?"
No, that is worse.
Use the default alignment:
  • select all text.
  • press ctrl + i
Did you read my comment about the outermost loop? It seems to be an attempt to duplicate all of the other loops, but as far as I can tell does nothing useful.

サインインしてコメントする。

採用された回答

Joe Vinciguerra
Joe Vinciguerra 2024 年 5 月 13 日
If you want to output to the command window during execution you have a couple options:
  1. The semicolon (;) at the end of each line suppresses output to the command window. Simply remove the semicolon at the end of the lines for which you would like to watch the values being returned.
  2. Use the disp function. This allows you to format your output and add additional information.
Here is an example of both methods:
for ii=1:3
foo = ii^2 % without semicolon the result is displayed in the command window
bar = ii/2; % with semicolon the result is suppressed
disp("The value of bar is " + string(bar));
end
foo = 1
The value of bar is 0.5
foo = 4
The value of bar is 1
foo = 9
The value of bar is 1.5
To interrogate your workspace "live" you will need to pause execution of the code using breakpoints. Here is how you do that:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeError Detection and Correction についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by