How to fix loop which over the determined index ?

1 vue (au cours des 30 derniers jours)
Arif
Arif le 15 Mai 2024
Commenté : Stephen23 le 15 Mai 2024
Hi guys, im trying to do looping ii 1:900 but why when u run it, it was never-ending loop. After reach 900, it will continue to 901 but using model with i = 1 (start again from beginning).
Here are my code:
%% clean-up the workspace & command window
clc;
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('B%d',1:1);
VariantTOS2 = compose('C%d',1:1);
VariantTOS3 = compose('D%d',1:1);
VariantBOS1 = compose('E%d',1:1);
VariantBOS2 = compose('F%d',1:1);
VariantBOS3 = compose('G%d',1:1);
VariantDOS1 = compose('H%d',1:1);
VariantDOS2 = compose('I%d',1:1);
VariantVOS = compose('J%d',1:1);
VariantTSS = compose('K%d',1:6);
VariantBSS = compose('L%d',1:6);
VariantDSS = compose('M%d',1:1);
VariantVSS = compose('N%d',1:1);
VariantCOL = compose('O%d',1:5);
%% 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:\\REF FAROS\\\MATLAB\\Prelim\\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,6.4,6.4);
ret = PropFrame.SetTube('B2','BJ-37',177,177,6.4,6.4);
ret = PropFrame.SetTube('B3','BJ-37',203,203,6.4,6.4);
% define frame section property for C(TOS2)
ret = PropFrame.SetTube('C1','BJ-37',152,152,7.9,7.9);
ret = PropFrame.SetTube('C2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('C3','BJ-37',203,203,7.9,7.9);
% define frame section property for D(TOS3)
ret = PropFrame.SetTube('D1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('D2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('D3','BJ-37',254,254,9.5,9.5);
% 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,6.4,6.4);
ret = PropFrame.SetTube('B3','BJ-37',203,203,6.4,6.4);
% define frame section property for F(BOS2)
ret = PropFrame.SetTube('F1','BJ-37',152,152,7.9,7.9);
ret = PropFrame.SetTube('F2','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('F3','BJ-37',203,203,7.9,7.9);
% define frame section property for G(BOS3)
ret = PropFrame.SetTube('G1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('G2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('G3','BJ-37',254,254,9.5,9.5);
% 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',177,177,7.9,7.9);
ret = PropFrame.SetTube('K2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('K3','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('K4','BJ-37',254,203,9.5,9.5);
ret = PropFrame.SetTube('K5','BJ-37',304,254,12.7,12.7);
ret = PropFrame.SetTube('K6','BJ-37',304,304,12.7,12.7);
% define frame section property for L(BSS)
ret = PropFrame.SetTube('L1','BJ-37',177,177,7.9,7.9);
ret = PropFrame.SetTube('L2','BJ-37',203,203,9.5,9.5);
ret = PropFrame.SetTube('L3','BJ-37',254,254,9.5,9.5);
ret = PropFrame.SetTube('L4','BJ-37',254,203,9.5,9.5);
ret = PropFrame.SetTube('L5','BJ-37',304,254,12.7,12.7);
ret = PropFrame.SetTube('L6','BJ-37',304,304,12.7,12.7);
% 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,304,15.9,15.9);
ret = PropFrame.SetTube('O2','BJ-37',455,250,15.9,15.9);
ret = PropFrame.SetTube('O3','BJ-37',508,250,15.9,15.9);
ret = PropFrame.SetTube('O4','BJ-37',508,304,19,19);
ret = PropFrame.SetTube('O5','BJ-37',600,304,19,19);
% 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:\\REF FAROS\\\MATLAB\\Prelim\\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;
%writecell(hingeresult,'hingeresult2173.xls')
writematrix(Specimen,'specimen2173.xls','Sheet',1)
writematrix(checkratio','checkratio2173.xls','Sheet',1)
writematrix(checkfuse','checkfuse2173.xls','Sheet',1)
%writecell(arrayfun(framefirstyield),'framefirstyield2173.xls','Sheet',1)
%writematrix(firstyieldlist,'firstyieldlist2173.xls','Sheet',1)
clc

Réponses (1)

Stephen23
Stephen23 le 15 Mai 2024
Modifié(e) : Stephen23 le 15 Mai 2024
"Hi guys, im trying to do looping ii 1:900 but why when u run it, it was never-ending loop."
I already told you the reason why, in my comment to your previous question:
Get rid of the outermost loop. Your outermost loop basically duplicates all of the other loops:
  • the outermost loop iterates 900 times,
  • within that you have lots of nested loops, which in total iterate 900 times,
  • so your code will perform 900*900 iterations in total.
GET RID OF THE OUTERMOST LOOP.
  2 commentaires
Arif
Arif le 15 Mai 2024
this one i dont understand may you give me the code directly based on my script?
S(1).name = "Model"
S(1).char = "";
S(1).vals = 2:2;
S(2).name = "ENDT";
S(2).char = "A";
S(2).vals = 1:5;
..
Stephen23
Stephen23 le 15 Mai 2024
"this one i dont understand may you give me the code directly based on my script?"
It is recommended to avoid meta-data in variable names, e.g. if you used e.g. the non-scalar structure as shown or similar approach then your code can be written in a more generalised way and likely without those deeply nested loops.
But that is just a recommended improvement.
To fix the bug you asked about in this thread, get rid of the outermost loop. That is all.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by