Category: Matlab
Category Archives: Matlab
I am using UV sensor and wanted the real time data to be exported to MATLAB in Real time. I need the continuous changes to be simultaneously noted
I wanted to work on the data that i get from the sensor. But couldn;t find a way to save the com3 output to csv file in the newer system.I wanted to work on the data that i get from the sensor. But couldn;t find a way to save the com3 output to csv file in the newer system. I wanted to work on the data that i get from the sensor. But couldn;t find a way to save the com3 output to csv file in the newer system. uv sensor MATLAB Answers — New Questions
Error during implementation of Wavelet based denoising using hybrid approach of adaptive flitering and single value decomposition
I want to denoise the signal using hybrid approach of adaptive flitering and single value decomposition. I have written the following code but it’s showing error in Line 32
S_thresh = diag(S – threshold*(S > threshold));
Following is the code and signal image with nosie:
clear all
clc
load("Signal")
% Load the noisy signal or image
noisy_signal = C;
% Set parameters
wavelet = ‘db2’; % Choose wavelet type
level = 5; % Decomposition level
threshold_type = ‘s’; % ‘s’ for soft thresholding, ‘h’ for hard thresholding
threshold_multiplier = median(abs(C)) / 0.6745; % Threshold multiplier for adaptive thresholding
% Perform wavelet decomposition
[c, l] = wavedec2(noisy_signal, level, wavelet);
% Initialize denoised coefficients
denoised_c = cell(1, level + 1);
% Loop through each detail coefficient subband for denoising
for i = 1:level
% Extract detail coefficients for current subband
cd = detcoef2(‘all’, c, l, i);
% Apply adaptive filtering
denoised_cd = zeros(size(cd));
for j = 1:size(cd, 1)
% Apply adaptive thresholding using singular value decomposition
[U, S, V] = svd(cd(j, :));
if threshold_type == ‘s’
threshold = threshold_multiplier * median(diag(S));
S_thresh = diag(S – threshold*(S > threshold));
elseif threshold_type == ‘h’
S_thresh = diag(S.*(abs(S) > threshold_multiplier * median(diag(S))));
end
denoised_cd(j, 🙂 = U * S_thresh * V’;
end
% Update denoised coefficients
denoised_c{i} = denoised_cd;
end
% Keep approximation coefficients as is
denoised_c{level + 1} = appcoef2(c, l, wavelet, level);
% Reconstruct the denoised signal or image
denoised_signal = waverec2(denoised_c, l, wavelet);
% Display the results
figure;
subplot(1, 2, 1);
imshow(noisy_signal);
title(‘Noisy Signal’);
subplot(1, 2, 2);
imshow(uint8(denoised_signal));
title(‘Denoised Signal’);I want to denoise the signal using hybrid approach of adaptive flitering and single value decomposition. I have written the following code but it’s showing error in Line 32
S_thresh = diag(S – threshold*(S > threshold));
Following is the code and signal image with nosie:
clear all
clc
load("Signal")
% Load the noisy signal or image
noisy_signal = C;
% Set parameters
wavelet = ‘db2’; % Choose wavelet type
level = 5; % Decomposition level
threshold_type = ‘s’; % ‘s’ for soft thresholding, ‘h’ for hard thresholding
threshold_multiplier = median(abs(C)) / 0.6745; % Threshold multiplier for adaptive thresholding
% Perform wavelet decomposition
[c, l] = wavedec2(noisy_signal, level, wavelet);
% Initialize denoised coefficients
denoised_c = cell(1, level + 1);
% Loop through each detail coefficient subband for denoising
for i = 1:level
% Extract detail coefficients for current subband
cd = detcoef2(‘all’, c, l, i);
% Apply adaptive filtering
denoised_cd = zeros(size(cd));
for j = 1:size(cd, 1)
% Apply adaptive thresholding using singular value decomposition
[U, S, V] = svd(cd(j, :));
if threshold_type == ‘s’
threshold = threshold_multiplier * median(diag(S));
S_thresh = diag(S – threshold*(S > threshold));
elseif threshold_type == ‘h’
S_thresh = diag(S.*(abs(S) > threshold_multiplier * median(diag(S))));
end
denoised_cd(j, 🙂 = U * S_thresh * V’;
end
% Update denoised coefficients
denoised_c{i} = denoised_cd;
end
% Keep approximation coefficients as is
denoised_c{level + 1} = appcoef2(c, l, wavelet, level);
% Reconstruct the denoised signal or image
denoised_signal = waverec2(denoised_c, l, wavelet);
% Display the results
figure;
subplot(1, 2, 1);
imshow(noisy_signal);
title(‘Noisy Signal’);
subplot(1, 2, 2);
imshow(uint8(denoised_signal));
title(‘Denoised Signal’); I want to denoise the signal using hybrid approach of adaptive flitering and single value decomposition. I have written the following code but it’s showing error in Line 32
S_thresh = diag(S – threshold*(S > threshold));
Following is the code and signal image with nosie:
clear all
clc
load("Signal")
% Load the noisy signal or image
noisy_signal = C;
% Set parameters
wavelet = ‘db2’; % Choose wavelet type
level = 5; % Decomposition level
threshold_type = ‘s’; % ‘s’ for soft thresholding, ‘h’ for hard thresholding
threshold_multiplier = median(abs(C)) / 0.6745; % Threshold multiplier for adaptive thresholding
% Perform wavelet decomposition
[c, l] = wavedec2(noisy_signal, level, wavelet);
% Initialize denoised coefficients
denoised_c = cell(1, level + 1);
% Loop through each detail coefficient subband for denoising
for i = 1:level
% Extract detail coefficients for current subband
cd = detcoef2(‘all’, c, l, i);
% Apply adaptive filtering
denoised_cd = zeros(size(cd));
for j = 1:size(cd, 1)
% Apply adaptive thresholding using singular value decomposition
[U, S, V] = svd(cd(j, :));
if threshold_type == ‘s’
threshold = threshold_multiplier * median(diag(S));
S_thresh = diag(S – threshold*(S > threshold));
elseif threshold_type == ‘h’
S_thresh = diag(S.*(abs(S) > threshold_multiplier * median(diag(S))));
end
denoised_cd(j, 🙂 = U * S_thresh * V’;
end
% Update denoised coefficients
denoised_c{i} = denoised_cd;
end
% Keep approximation coefficients as is
denoised_c{level + 1} = appcoef2(c, l, wavelet, level);
% Reconstruct the denoised signal or image
denoised_signal = waverec2(denoised_c, l, wavelet);
% Display the results
figure;
subplot(1, 2, 1);
imshow(noisy_signal);
title(‘Noisy Signal’);
subplot(1, 2, 2);
imshow(uint8(denoised_signal));
title(‘Denoised Signal’); wavelet denoising, partial discharge signal, single value decomopsition (svd), adaptive flitering MATLAB Answers — New Questions
trucksim-simulink co-simulaition
I use Simulink and Trucksim for co-simulation. Sometimes it works well, but sometimes it keeps reporting errors, indicating that the model in Trucksim is unstable. However, running the simulation alone in Trucksim can proceed normallyI use Simulink and Trucksim for co-simulation. Sometimes it works well, but sometimes it keeps reporting errors, indicating that the model in Trucksim is unstable. However, running the simulation alone in Trucksim can proceed normally I use Simulink and Trucksim for co-simulation. Sometimes it works well, but sometimes it keeps reporting errors, indicating that the model in Trucksim is unstable. However, running the simulation alone in Trucksim can proceed normally co-simulation, simulink, trucksim MATLAB Answers — New Questions
How to code equation
Hello, just wondering if this equation could be coded like this:
Any feedback will be greatly appreciated. Thanks
m = 10e-3
a = 0.05
c = 0.1
x(t) = m/a e^-(c/a)tHello, just wondering if this equation could be coded like this:
Any feedback will be greatly appreciated. Thanks
m = 10e-3
a = 0.05
c = 0.1
x(t) = m/a e^-(c/a)t Hello, just wondering if this equation could be coded like this:
Any feedback will be greatly appreciated. Thanks
m = 10e-3
a = 0.05
c = 0.1
x(t) = m/a e^-(c/a)t equation code MATLAB Answers — New Questions
Which technique to use for Satellite Imagery?
Hello,
I am new to image classification and am seeking to classify oil spills in SAR imagery using an unsupervised or adaptive thresholding method. I have experimented with various thresholding techniques, including Otsu, but none have consistently performed well across all SAR satellite images. While Otsu’s method yields satisfactory results for some images, those containing land areas often obscure the oil spill, as depicted in the attached image.
Additionally, I have attempted mean shift segmentation, but it lacks adaptability, requiring a separate bandwidth setting for each image.
Could anyone provide guidance on which method or combination of methods to employ in order to achieve the desired results?
Thank youHello,
I am new to image classification and am seeking to classify oil spills in SAR imagery using an unsupervised or adaptive thresholding method. I have experimented with various thresholding techniques, including Otsu, but none have consistently performed well across all SAR satellite images. While Otsu’s method yields satisfactory results for some images, those containing land areas often obscure the oil spill, as depicted in the attached image.
Additionally, I have attempted mean shift segmentation, but it lacks adaptability, requiring a separate bandwidth setting for each image.
Could anyone provide guidance on which method or combination of methods to employ in order to achieve the desired results?
Thank you Hello,
I am new to image classification and am seeking to classify oil spills in SAR imagery using an unsupervised or adaptive thresholding method. I have experimented with various thresholding techniques, including Otsu, but none have consistently performed well across all SAR satellite images. While Otsu’s method yields satisfactory results for some images, those containing land areas often obscure the oil spill, as depicted in the attached image.
Additionally, I have attempted mean shift segmentation, but it lacks adaptability, requiring a separate bandwidth setting for each image.
Could anyone provide guidance on which method or combination of methods to employ in order to achieve the desired results?
Thank you classification, image segmentation, computer vision, image processing, satellite imagery, sar MATLAB Answers — New Questions
Transfer Learning using deepNetwork Designer to show Precision and Recall, F1 score, Mean Average Precision and Mean Absolute Error.
I have tried to use deepNetwork Designer to perform Transfer Learning and have used Darknet53 network. Then I set my images (already preprocessed images of Person) to be the Data. After setting the Training Options, I proceeded to Training. I can see the on the results the Accuracy, Loss, and other info. However, I want to know if it’s possible to also show the Precision and Recall, F1 Score, Mean Average Precision? I am trying to find detailed documentations and would love to hear from other experts here. I am still exploring Experiment Manager if it’s possible there but am hoping somebody here who has a commendable idea on how to do these? Thank you so much.I have tried to use deepNetwork Designer to perform Transfer Learning and have used Darknet53 network. Then I set my images (already preprocessed images of Person) to be the Data. After setting the Training Options, I proceeded to Training. I can see the on the results the Accuracy, Loss, and other info. However, I want to know if it’s possible to also show the Precision and Recall, F1 Score, Mean Average Precision? I am trying to find detailed documentations and would love to hear from other experts here. I am still exploring Experiment Manager if it’s possible there but am hoping somebody here who has a commendable idea on how to do these? Thank you so much. I have tried to use deepNetwork Designer to perform Transfer Learning and have used Darknet53 network. Then I set my images (already preprocessed images of Person) to be the Data. After setting the Training Options, I proceeded to Training. I can see the on the results the Accuracy, Loss, and other info. However, I want to know if it’s possible to also show the Precision and Recall, F1 Score, Mean Average Precision? I am trying to find detailed documentations and would love to hear from other experts here. I am still exploring Experiment Manager if it’s possible there but am hoping somebody here who has a commendable idea on how to do these? Thank you so much. #deep learning, #transfer learning, #darknet53, imageclassification MATLAB Answers — New Questions
zcv variable Potential conflicting usages of identifier
Hello,
What’s a ZCV variable ? I am trying to generate code from a model that contains several referenced models, and I am getting this error:
Potential conflicting usages of identifier ‘ZCV_pidController_T’: a global identifier from ‘speed_controller’, and a global identifier from ‘current_controller’ This conflict may be resolved by either increasing the maximum identifier length on the Identifiers pane of the Configuration Parameters dialog box or by changing the name of the conflicting identifier.
I tried increasing the identifier max length it did not workHello,
What’s a ZCV variable ? I am trying to generate code from a model that contains several referenced models, and I am getting this error:
Potential conflicting usages of identifier ‘ZCV_pidController_T’: a global identifier from ‘speed_controller’, and a global identifier from ‘current_controller’ This conflict may be resolved by either increasing the maximum identifier length on the Identifiers pane of the Configuration Parameters dialog box or by changing the name of the conflicting identifier.
I tried increasing the identifier max length it did not work Hello,
What’s a ZCV variable ? I am trying to generate code from a model that contains several referenced models, and I am getting this error:
Potential conflicting usages of identifier ‘ZCV_pidController_T’: a global identifier from ‘speed_controller’, and a global identifier from ‘current_controller’ This conflict may be resolved by either increasing the maximum identifier length on the Identifiers pane of the Configuration Parameters dialog box or by changing the name of the conflicting identifier.
I tried increasing the identifier max length it did not work embedded coder, simulink MATLAB Answers — New Questions
How to import MATLAB generated ARXML file.
Hello,
I have created a SIMULINK model using AUTOSAR architecture blockset and generated ARXML code from it.
I need to import same model using import commands but it is throughing errors. Is it possible to do so?
If yes what is the correct process and commands required.
Regards,
Varun SinghHello,
I have created a SIMULINK model using AUTOSAR architecture blockset and generated ARXML code from it.
I need to import same model using import commands but it is throughing errors. Is it possible to do so?
If yes what is the correct process and commands required.
Regards,
Varun Singh Hello,
I have created a SIMULINK model using AUTOSAR architecture blockset and generated ARXML code from it.
I need to import same model using import commands but it is throughing errors. Is it possible to do so?
If yes what is the correct process and commands required.
Regards,
Varun Singh smiulink, arxml, import MATLAB Answers — New Questions
Cannot find the pointers in my Simulink model, need to remove them for code generation
Hello all,
I am relatively new in the ways of code generation in Simulink and I’ve run into a problem.
When I try to convert a subsystem to PLC code (CoDeSyS 3.5), Simulink throws the following error:
Error:The model requires pointer type representation. This is not supported by Simulink PLC Coder.
### PLC code generation failed for ‘UnderStruct_Mod_V1/Understructure’
I barely understand what a ‘pointer type representation’ is and I’m sure I’ve not included the need for pointers on purpose. I have exhausted my google-skills on this problem and honestly have no idea where to look anymore. Could someone please point me in the right direction? Is there a box that I should check or uncheck? Are there some elements in my model that force the use of pointers?
Much appreciatedHello all,
I am relatively new in the ways of code generation in Simulink and I’ve run into a problem.
When I try to convert a subsystem to PLC code (CoDeSyS 3.5), Simulink throws the following error:
Error:The model requires pointer type representation. This is not supported by Simulink PLC Coder.
### PLC code generation failed for ‘UnderStruct_Mod_V1/Understructure’
I barely understand what a ‘pointer type representation’ is and I’m sure I’ve not included the need for pointers on purpose. I have exhausted my google-skills on this problem and honestly have no idea where to look anymore. Could someone please point me in the right direction? Is there a box that I should check or uncheck? Are there some elements in my model that force the use of pointers?
Much appreciated Hello all,
I am relatively new in the ways of code generation in Simulink and I’ve run into a problem.
When I try to convert a subsystem to PLC code (CoDeSyS 3.5), Simulink throws the following error:
Error:The model requires pointer type representation. This is not supported by Simulink PLC Coder.
### PLC code generation failed for ‘UnderStruct_Mod_V1/Understructure’
I barely understand what a ‘pointer type representation’ is and I’m sure I’ve not included the need for pointers on purpose. I have exhausted my google-skills on this problem and honestly have no idea where to look anymore. Could someone please point me in the right direction? Is there a box that I should check or uncheck? Are there some elements in my model that force the use of pointers?
Much appreciated plc code generator MATLAB Answers — New Questions
Plotting S parameters in Matlab
Hi. So I’m trying to plot S parameters of a system. I need to plot S11 and S21 and have equations for both (derived from network synthesis data). Now my question is:
1) should I use
sparameters(S11,f)
command if the equation for S11 that I have in the code already defines it as S parameter?
S11(1,x)=1+2*i*Rs*inv(A(1,1));
A changes with frequency, and my code is designed such that every value of A(1,1) yeilds a different S11 parameter and that is stored in location (1,x) with x increasing with each cycle (x=x+1).
2) I’m not getting the right curve with or without using the sparameters command. Also rfplot and plot yield the same incorrect curve. Should S11 be in dB?Hi. So I’m trying to plot S parameters of a system. I need to plot S11 and S21 and have equations for both (derived from network synthesis data). Now my question is:
1) should I use
sparameters(S11,f)
command if the equation for S11 that I have in the code already defines it as S parameter?
S11(1,x)=1+2*i*Rs*inv(A(1,1));
A changes with frequency, and my code is designed such that every value of A(1,1) yeilds a different S11 parameter and that is stored in location (1,x) with x increasing with each cycle (x=x+1).
2) I’m not getting the right curve with or without using the sparameters command. Also rfplot and plot yield the same incorrect curve. Should S11 be in dB? Hi. So I’m trying to plot S parameters of a system. I need to plot S11 and S21 and have equations for both (derived from network synthesis data). Now my question is:
1) should I use
sparameters(S11,f)
command if the equation for S11 that I have in the code already defines it as S parameter?
S11(1,x)=1+2*i*Rs*inv(A(1,1));
A changes with frequency, and my code is designed such that every value of A(1,1) yeilds a different S11 parameter and that is stored in location (1,x) with x increasing with each cycle (x=x+1).
2) I’m not getting the right curve with or without using the sparameters command. Also rfplot and plot yield the same incorrect curve. Should S11 be in dB? s parameters, s11, s-parameter MATLAB Answers — New Questions
How to connect with QGroundControl via Telemetry Radios in PX4 support package?
We want to connect with QGroundControl via Telemetry Radios but we get the following error:
Error on link Serial Device on COM6. Error connecting: Could not create port. Access is denied
In my web searches related to the error, I came across the following link: https://www.mathworks.com/matlabcentral/answers/471513-solved-how-to-send-serial-data-over-telemetry-radio-px4-autopilots-support-from-embedded-coder
It talks about using a companion computer like Raspberry Pi to make it happen. It seems here the support package does not support communication by telemetry.
Is there a way to communicate with telemetry radios without using a Companion computer?We want to connect with QGroundControl via Telemetry Radios but we get the following error:
Error on link Serial Device on COM6. Error connecting: Could not create port. Access is denied
In my web searches related to the error, I came across the following link: https://www.mathworks.com/matlabcentral/answers/471513-solved-how-to-send-serial-data-over-telemetry-radio-px4-autopilots-support-from-embedded-coder
It talks about using a companion computer like Raspberry Pi to make it happen. It seems here the support package does not support communication by telemetry.
Is there a way to communicate with telemetry radios without using a Companion computer? We want to connect with QGroundControl via Telemetry Radios but we get the following error:
Error on link Serial Device on COM6. Error connecting: Could not create port. Access is denied
In my web searches related to the error, I came across the following link: https://www.mathworks.com/matlabcentral/answers/471513-solved-how-to-send-serial-data-over-telemetry-radio-px4-autopilots-support-from-embedded-coder
It talks about using a companion computer like Raspberry Pi to make it happen. It seems here the support package does not support communication by telemetry.
Is there a way to communicate with telemetry radios without using a Companion computer? MATLAB Answers — New Questions
Reusable functions (embedded coder) and model reference
I have a model A which contains two other models B and C through the model referencing. All this models use a block defined in a custom library.
I have set "Function packaging: Reusable function" for the library block. By this way each model (A, B or C) reuse code for the block. However in the generated C code, for each model I have a different function (with different signature but the same implementation).
I would create reusable code for the library block. That is I want only one implementation for the function called by all the models A, B and C.
I tried to set function name and File name for the library block but I get an error
"Potential conflicting usages of identifier ‘rtZCSV_GainLib’: a global identifier from model B, and a global identifier from model C
The conflict may be resolved by increasing the maximum identifier length on the Symbols pane of the Configuration Parameters dialog box. Otherwise the conflicting identifiers need to be renamed."
Is it possible generate only one implementation for the library block in a given c files and configure all the models A, B, C in a way that they call the same function? What are the settings I have to use?
Thanks,
PaoloI have a model A which contains two other models B and C through the model referencing. All this models use a block defined in a custom library.
I have set "Function packaging: Reusable function" for the library block. By this way each model (A, B or C) reuse code for the block. However in the generated C code, for each model I have a different function (with different signature but the same implementation).
I would create reusable code for the library block. That is I want only one implementation for the function called by all the models A, B and C.
I tried to set function name and File name for the library block but I get an error
"Potential conflicting usages of identifier ‘rtZCSV_GainLib’: a global identifier from model B, and a global identifier from model C
The conflict may be resolved by increasing the maximum identifier length on the Symbols pane of the Configuration Parameters dialog box. Otherwise the conflicting identifiers need to be renamed."
Is it possible generate only one implementation for the library block in a given c files and configure all the models A, B, C in a way that they call the same function? What are the settings I have to use?
Thanks,
Paolo I have a model A which contains two other models B and C through the model referencing. All this models use a block defined in a custom library.
I have set "Function packaging: Reusable function" for the library block. By this way each model (A, B or C) reuse code for the block. However in the generated C code, for each model I have a different function (with different signature but the same implementation).
I would create reusable code for the library block. That is I want only one implementation for the function called by all the models A, B and C.
I tried to set function name and File name for the library block but I get an error
"Potential conflicting usages of identifier ‘rtZCSV_GainLib’: a global identifier from model B, and a global identifier from model C
The conflict may be resolved by increasing the maximum identifier length on the Symbols pane of the Configuration Parameters dialog box. Otherwise the conflicting identifiers need to be renamed."
Is it possible generate only one implementation for the library block in a given c files and configure all the models A, B, C in a way that they call the same function? What are the settings I have to use?
Thanks,
Paolo embedded coder simulink function library reuse code model reference MATLAB Answers — New Questions
How do I export my app to a pdf without clipping?
I want to export my app to a pdf report. I am using the code below (straight from the example for "exportapp":
% Button pushed function: ExportDataButton
function ExportDataButtonPushed(app, event)
filter = {‘*.jpg’;’*.png’;’*.tif’;’*.pdf’};
[filename,filepath] = uiputfile(filter);
if ischar(filename)
exportapp(app.VisionMetricsUIFigure,[filepath filename]);
end
end
When I choose a file name as an image, everything displays as expected. When I create a pdf, it clips off the right/bottom of the app.
I initially thought it might be related to the app size, so I tried to shrink it to the area that was displayed, but it still clipped in the same area.
Original Size: 952×761
New Size: 876×638
How can I get everything to display when saved as a pdf?I want to export my app to a pdf report. I am using the code below (straight from the example for "exportapp":
% Button pushed function: ExportDataButton
function ExportDataButtonPushed(app, event)
filter = {‘*.jpg’;’*.png’;’*.tif’;’*.pdf’};
[filename,filepath] = uiputfile(filter);
if ischar(filename)
exportapp(app.VisionMetricsUIFigure,[filepath filename]);
end
end
When I choose a file name as an image, everything displays as expected. When I create a pdf, it clips off the right/bottom of the app.
I initially thought it might be related to the app size, so I tried to shrink it to the area that was displayed, but it still clipped in the same area.
Original Size: 952×761
New Size: 876×638
How can I get everything to display when saved as a pdf? I want to export my app to a pdf report. I am using the code below (straight from the example for "exportapp":
% Button pushed function: ExportDataButton
function ExportDataButtonPushed(app, event)
filter = {‘*.jpg’;’*.png’;’*.tif’;’*.pdf’};
[filename,filepath] = uiputfile(filter);
if ischar(filename)
exportapp(app.VisionMetricsUIFigure,[filepath filename]);
end
end
When I choose a file name as an image, everything displays as expected. When I create a pdf, it clips off the right/bottom of the app.
I initially thought it might be related to the app size, so I tried to shrink it to the area that was displayed, but it still clipped in the same area.
Original Size: 952×761
New Size: 876×638
How can I get everything to display when saved as a pdf? app designer, pdf MATLAB Answers — New Questions
How to fix loop which over the determined index ?
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 FilesComputers and StructuresSAP2000 25SAP2000.exe’;
% full path to API dll set it to the installation folder
APIDLLPath = ‘C:Program FilesComputers and StructuresSAP2000 25SAP2000v1.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)
clcHi 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 FilesComputers and StructuresSAP2000 25SAP2000.exe’;
% full path to API dll set it to the installation folder
APIDLLPath = ‘C:Program FilesComputers and StructuresSAP2000 25SAP2000v1.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 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 FilesComputers and StructuresSAP2000 25SAP2000.exe’;
% full path to API dll set it to the installation folder
APIDLLPath = ‘C:Program FilesComputers and StructuresSAP2000 25SAP2000v1.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 loops, loop error, outloop MATLAB Answers — New Questions
how to get p-values from fit function
Hello, i’m trying to get p-value from a fitting performed with fit function, but i cannot find how to do so, i can only get r2 and RMSE.
Should i use some other function rather than fit?
here my code and the data, hope it will be understandable. thanks you very much in advance.
ft = fittype(‘(m*c*k*x)/((1-k*x)*(1+(c-1)*k*x))’, …
‘dependent’,{‘y’}, …
‘independent’,{‘x’}, …
‘coefficients’,{‘m’,’c’,’k’});
coef = ["Xm","Cg","K","R2","RMSE"];
figure (1);
[f,gof] = fit(x,y, ft,’StartPoint’,[0.2, 5, 1]);
plot(f);
hold on
plot(x,y);
figure(2);
plot(f,x,y,"residuals");
%save coefficients
format long g
c = coeffvalues(f);
R2 = gof.rsquare;
RMSE = gof.rmse;
r = horzcat(c,R2,RMSE);
coef = [coef;r];Hello, i’m trying to get p-value from a fitting performed with fit function, but i cannot find how to do so, i can only get r2 and RMSE.
Should i use some other function rather than fit?
here my code and the data, hope it will be understandable. thanks you very much in advance.
ft = fittype(‘(m*c*k*x)/((1-k*x)*(1+(c-1)*k*x))’, …
‘dependent’,{‘y’}, …
‘independent’,{‘x’}, …
‘coefficients’,{‘m’,’c’,’k’});
coef = ["Xm","Cg","K","R2","RMSE"];
figure (1);
[f,gof] = fit(x,y, ft,’StartPoint’,[0.2, 5, 1]);
plot(f);
hold on
plot(x,y);
figure(2);
plot(f,x,y,"residuals");
%save coefficients
format long g
c = coeffvalues(f);
R2 = gof.rsquare;
RMSE = gof.rmse;
r = horzcat(c,R2,RMSE);
coef = [coef;r]; Hello, i’m trying to get p-value from a fitting performed with fit function, but i cannot find how to do so, i can only get r2 and RMSE.
Should i use some other function rather than fit?
here my code and the data, hope it will be understandable. thanks you very much in advance.
ft = fittype(‘(m*c*k*x)/((1-k*x)*(1+(c-1)*k*x))’, …
‘dependent’,{‘y’}, …
‘independent’,{‘x’}, …
‘coefficients’,{‘m’,’c’,’k’});
coef = ["Xm","Cg","K","R2","RMSE"];
figure (1);
[f,gof] = fit(x,y, ft,’StartPoint’,[0.2, 5, 1]);
plot(f);
hold on
plot(x,y);
figure(2);
plot(f,x,y,"residuals");
%save coefficients
format long g
c = coeffvalues(f);
R2 = gof.rsquare;
RMSE = gof.rmse;
r = horzcat(c,R2,RMSE);
coef = [coef;r]; curve fitting, p value MATLAB Answers — New Questions
permutation in regression learner app
I am using statistical and machine learning toolbox to find a best model to predict my variable of interest. After having caculated my best model how can I compute permuation to asses the p value?I am using statistical and machine learning toolbox to find a best model to predict my variable of interest. After having caculated my best model how can I compute permuation to asses the p value? I am using statistical and machine learning toolbox to find a best model to predict my variable of interest. After having caculated my best model how can I compute permuation to asses the p value? #permutation #machinelearning #regression learner MATLAB Answers — New Questions
How to preserve subscript or superscript formatting in a text string?
I’m reading out some text strings (units) from some Excel files:
filename = ‘AAA.xlsx’;
opt = detectImportOptions(filename);
opt.VariableUnitsRange = ‘2:2’; % 2nd row
T1 = readtable(filename, opt);
The problem is that I would have a unit like this: mol kg^-1, and after it is read out, the superscript formatting of "-1" is lost.
Is there an option so that I could preserve the superscript formatting?
Thanks.I’m reading out some text strings (units) from some Excel files:
filename = ‘AAA.xlsx’;
opt = detectImportOptions(filename);
opt.VariableUnitsRange = ‘2:2’; % 2nd row
T1 = readtable(filename, opt);
The problem is that I would have a unit like this: mol kg^-1, and after it is read out, the superscript formatting of "-1" is lost.
Is there an option so that I could preserve the superscript formatting?
Thanks. I’m reading out some text strings (units) from some Excel files:
filename = ‘AAA.xlsx’;
opt = detectImportOptions(filename);
opt.VariableUnitsRange = ‘2:2’; % 2nd row
T1 = readtable(filename, opt);
The problem is that I would have a unit like this: mol kg^-1, and after it is read out, the superscript formatting of "-1" is lost.
Is there an option so that I could preserve the superscript formatting?
Thanks. readtable, superscript MATLAB Answers — New Questions
How to train a Gaussian Process Regression Model to produce a single output based on multiple input?
I have a set of test data containing 5 input variables and 1 output. There are 3 sets of such data.
I would like to train a machine learning (Gaussian Process Regression Model) to predict the output when the input variables are changed to other random values. I have tried following the example on https://uk.mathworks.com/help/stats/gaussian-process-regression-models.html where I modified the example code by the following:
In the example code, it was input as:
x_observed = linspace(0,10,21)’;
y_observed1 = x_observed.*sin(x_observed);
y_observed2 = y_observed1 + 0.5*randn(size(x_observed));
How do I modify the x_observed to contain 5 input variables and the y_observed to contain the output variable for each of the 3 sets of test data? This is what I have done so far:
% Sample input matrices
% matrix(design no.) = [var1 var2 var3 var4 var5]
matrix1 = [0.9 120 25 450 12];
matrix2 = [2.25 200 35 920 14];
matrix3 = [0.9 200 35 920 14];
% definition of output variable
% "Y" (output) = membrane + bending stress, in MPa, from ANSYS FEM model
%Sample output matrices
% o(design no.) = [membrane + bending stress in MPa]
o1 = [242.81];
o2 = [237.09];
o3 = [213.18];
Any help would be appreciated, thank you.
Regards,
KTI have a set of test data containing 5 input variables and 1 output. There are 3 sets of such data.
I would like to train a machine learning (Gaussian Process Regression Model) to predict the output when the input variables are changed to other random values. I have tried following the example on https://uk.mathworks.com/help/stats/gaussian-process-regression-models.html where I modified the example code by the following:
In the example code, it was input as:
x_observed = linspace(0,10,21)’;
y_observed1 = x_observed.*sin(x_observed);
y_observed2 = y_observed1 + 0.5*randn(size(x_observed));
How do I modify the x_observed to contain 5 input variables and the y_observed to contain the output variable for each of the 3 sets of test data? This is what I have done so far:
% Sample input matrices
% matrix(design no.) = [var1 var2 var3 var4 var5]
matrix1 = [0.9 120 25 450 12];
matrix2 = [2.25 200 35 920 14];
matrix3 = [0.9 200 35 920 14];
% definition of output variable
% "Y" (output) = membrane + bending stress, in MPa, from ANSYS FEM model
%Sample output matrices
% o(design no.) = [membrane + bending stress in MPa]
o1 = [242.81];
o2 = [237.09];
o3 = [213.18];
Any help would be appreciated, thank you.
Regards,
KT I have a set of test data containing 5 input variables and 1 output. There are 3 sets of such data.
I would like to train a machine learning (Gaussian Process Regression Model) to predict the output when the input variables are changed to other random values. I have tried following the example on https://uk.mathworks.com/help/stats/gaussian-process-regression-models.html where I modified the example code by the following:
In the example code, it was input as:
x_observed = linspace(0,10,21)’;
y_observed1 = x_observed.*sin(x_observed);
y_observed2 = y_observed1 + 0.5*randn(size(x_observed));
How do I modify the x_observed to contain 5 input variables and the y_observed to contain the output variable for each of the 3 sets of test data? This is what I have done so far:
% Sample input matrices
% matrix(design no.) = [var1 var2 var3 var4 var5]
matrix1 = [0.9 120 25 450 12];
matrix2 = [2.25 200 35 920 14];
matrix3 = [0.9 200 35 920 14];
% definition of output variable
% "Y" (output) = membrane + bending stress, in MPa, from ANSYS FEM model
%Sample output matrices
% o(design no.) = [membrane + bending stress in MPa]
o1 = [242.81];
o2 = [237.09];
o3 = [213.18];
Any help would be appreciated, thank you.
Regards,
KT gaussian process regression model, machine learning MATLAB Answers — New Questions
How to optimize the antenna weight of a two-dimensional array to generate null in a specific direction
I have read the” Array Pattern Synthesis Part II: Optimization“,the optimization example is for one-dimensional array(ULA), and there are problems in my process of weight optimization for two-dimensional array(URA),Please give me some guidance,thanks!
N = 8;
M=8;
URA1 = phased.URA(‘Size’,[N,M],’ArrayNormal’,’z’);
pos = getElementPosition(URA1);
% position of elements
ang_i = [-70 -40 -20;0 0 0]; % interference angles
ang_d = [0;0]; % desired angle
Rn = sensorcov(pos,ang_i,db2pow(-40)); % Noise covariance matrix
sv_c = steervec(pos,[ang_d ang_i]); % Linear constraints
r_c = [1 zeros(size(ang_i))]’; % Desired response
w_lcmv = lcmvweights(sv_c,r_c,Rn); % LCMV weights
ang_plot = -90:0.1:90;
sv_plot = steervec(pos,ang_plot);
plcmv = plot(ang_plot,mag2db(abs(w_lcmv’*sv_plot)));
xline(ang_i,"–")
ylim([-100 0])
grid on
legend(plcmv,"LCMV – Analytic")
xlabel("Azimuth Angle (deg)")
ylabel("Beam Pattern (dB)")I have read the” Array Pattern Synthesis Part II: Optimization“,the optimization example is for one-dimensional array(ULA), and there are problems in my process of weight optimization for two-dimensional array(URA),Please give me some guidance,thanks!
N = 8;
M=8;
URA1 = phased.URA(‘Size’,[N,M],’ArrayNormal’,’z’);
pos = getElementPosition(URA1);
% position of elements
ang_i = [-70 -40 -20;0 0 0]; % interference angles
ang_d = [0;0]; % desired angle
Rn = sensorcov(pos,ang_i,db2pow(-40)); % Noise covariance matrix
sv_c = steervec(pos,[ang_d ang_i]); % Linear constraints
r_c = [1 zeros(size(ang_i))]’; % Desired response
w_lcmv = lcmvweights(sv_c,r_c,Rn); % LCMV weights
ang_plot = -90:0.1:90;
sv_plot = steervec(pos,ang_plot);
plcmv = plot(ang_plot,mag2db(abs(w_lcmv’*sv_plot)));
xline(ang_i,"–")
ylim([-100 0])
grid on
legend(plcmv,"LCMV – Analytic")
xlabel("Azimuth Angle (deg)")
ylabel("Beam Pattern (dB)") I have read the” Array Pattern Synthesis Part II: Optimization“,the optimization example is for one-dimensional array(ULA), and there are problems in my process of weight optimization for two-dimensional array(URA),Please give me some guidance,thanks!
N = 8;
M=8;
URA1 = phased.URA(‘Size’,[N,M],’ArrayNormal’,’z’);
pos = getElementPosition(URA1);
% position of elements
ang_i = [-70 -40 -20;0 0 0]; % interference angles
ang_d = [0;0]; % desired angle
Rn = sensorcov(pos,ang_i,db2pow(-40)); % Noise covariance matrix
sv_c = steervec(pos,[ang_d ang_i]); % Linear constraints
r_c = [1 zeros(size(ang_i))]’; % Desired response
w_lcmv = lcmvweights(sv_c,r_c,Rn); % LCMV weights
ang_plot = -90:0.1:90;
sv_plot = steervec(pos,ang_plot);
plcmv = plot(ang_plot,mag2db(abs(w_lcmv’*sv_plot)));
xline(ang_i,"–")
ylim([-100 0])
grid on
legend(plcmv,"LCMV – Analytic")
xlabel("Azimuth Angle (deg)")
ylabel("Beam Pattern (dB)") ura, phased array, beamform, upa MATLAB Answers — New Questions
Where do I get the Data Set of EMG Signals with Standard features
I need to make a classification of EMG signals throgh features analysis.So that I need Standard featutres of EMG Signals.So that with the Standatd data ,i can compare the diseases DataI need to make a classification of EMG signals throgh features analysis.So that I need Standard featutres of EMG Signals.So that with the Standatd data ,i can compare the diseases Data I need to make a classification of EMG signals throgh features analysis.So that I need Standard featutres of EMG Signals.So that with the Standatd data ,i can compare the diseases Data emg stamdatrd data MATLAB Answers — New Questions