Category: Matlab
Category Archives: Matlab
RREF with unknown variables
Hi
Suppose I have an augmented matrix with unknown variables and I want to reduce it to its reduced row echelon form. How to do this in Matlab ?
Example matrix:
[1, 2, 3, a;
4, 5, 6, b;
7, 8, 9, c;]
Thanks for advance!Hi
Suppose I have an augmented matrix with unknown variables and I want to reduce it to its reduced row echelon form. How to do this in Matlab ?
Example matrix:
[1, 2, 3, a;
4, 5, 6, b;
7, 8, 9, c;]
Thanks for advance! Hi
Suppose I have an augmented matrix with unknown variables and I want to reduce it to its reduced row echelon form. How to do this in Matlab ?
Example matrix:
[1, 2, 3, a;
4, 5, 6, b;
7, 8, 9, c;]
Thanks for advance! rref, unknown, variable MATLAB Answers — New Questions
Error in code, bracket perceiving as comment for some reason
If a run a following code i get a following comment: Line 17: A'(‘migh be missing a closing’)’. causing invalid syntax at end of line. Line 17 is Q_est = updateQ(…), and this warning also shows in line 18 and 19 too. Does anyone know what is the problem? Fere we cannot see it but if I run this code in Matlab the last bracket is shown in green and perceived as comment for some reason
for i = 1:numIterations
beta_est = updateBetaUsingCarterKohn(Y, X, alpha_est, beta_est, Q_est, R_est);
Q_est = updateQ(…)
R_est = updateR(…)
alpha_est = updateAlpha(…)
endIf a run a following code i get a following comment: Line 17: A'(‘migh be missing a closing’)’. causing invalid syntax at end of line. Line 17 is Q_est = updateQ(…), and this warning also shows in line 18 and 19 too. Does anyone know what is the problem? Fere we cannot see it but if I run this code in Matlab the last bracket is shown in green and perceived as comment for some reason
for i = 1:numIterations
beta_est = updateBetaUsingCarterKohn(Y, X, alpha_est, beta_est, Q_est, R_est);
Q_est = updateQ(…)
R_est = updateR(…)
alpha_est = updateAlpha(…)
end If a run a following code i get a following comment: Line 17: A'(‘migh be missing a closing’)’. causing invalid syntax at end of line. Line 17 is Q_est = updateQ(…), and this warning also shows in line 18 and 19 too. Does anyone know what is the problem? Fere we cannot see it but if I run this code in Matlab the last bracket is shown in green and perceived as comment for some reason
for i = 1:numIterations
beta_est = updateBetaUsingCarterKohn(Y, X, alpha_est, beta_est, Q_est, R_est);
Q_est = updateQ(…)
R_est = updateR(…)
alpha_est = updateAlpha(…)
end error, comment, code, help MATLAB Answers — New Questions
i want to solve 3 non linear equations in matlab
eq1= 72.25+23.29*x-25.79*y-6.592*x*y-27.98*y^2-7.255*x*y^2+6.918*y^3-e1 =0;
eq2= 46.99+15.46*x+9.358*y+0.6696*x*y-19.9*y^2-5.869*x*y^2-4.47*y^3-e2=0;
eq3= 20.22+6.611*x+12.02*y+2.7*x*y-6.497*y^2-2.425*x*y^2-4.529*y^3-e3 =0 ;
I gave 3 non linear equations above and I want to find solution of x and y . e1 e2 e3 let e1 e2 e3 are unknown constants .I want the solution x and y must be in terms or fuction of e1,e2,e3 . So I want a program in matlab with solution as soon as possible.eq1= 72.25+23.29*x-25.79*y-6.592*x*y-27.98*y^2-7.255*x*y^2+6.918*y^3-e1 =0;
eq2= 46.99+15.46*x+9.358*y+0.6696*x*y-19.9*y^2-5.869*x*y^2-4.47*y^3-e2=0;
eq3= 20.22+6.611*x+12.02*y+2.7*x*y-6.497*y^2-2.425*x*y^2-4.529*y^3-e3 =0 ;
I gave 3 non linear equations above and I want to find solution of x and y . e1 e2 e3 let e1 e2 e3 are unknown constants .I want the solution x and y must be in terms or fuction of e1,e2,e3 . So I want a program in matlab with solution as soon as possible. eq1= 72.25+23.29*x-25.79*y-6.592*x*y-27.98*y^2-7.255*x*y^2+6.918*y^3-e1 =0;
eq2= 46.99+15.46*x+9.358*y+0.6696*x*y-19.9*y^2-5.869*x*y^2-4.47*y^3-e2=0;
eq3= 20.22+6.611*x+12.02*y+2.7*x*y-6.497*y^2-2.425*x*y^2-4.529*y^3-e3 =0 ;
I gave 3 non linear equations above and I want to find solution of x and y . e1 e2 e3 let e1 e2 e3 are unknown constants .I want the solution x and y must be in terms or fuction of e1,e2,e3 . So I want a program in matlab with solution as soon as possible. syms MATLAB Answers — New Questions
Send more than one value in Field 1. Buffer of values.
Hello! I would like to know if any of you know how I could send a list of values all as field1.
From postman it would look something like this:
The data is sent because I can see it by downloading the excel but not graphed. Do you know if it is possible to send them all together and graph them?
ThanksHello! I would like to know if any of you know how I could send a list of values all as field1.
From postman it would look something like this:
The data is sent because I can see it by downloading the excel but not graphed. Do you know if it is possible to send them all together and graph them?
Thanks Hello! I would like to know if any of you know how I could send a list of values all as field1.
From postman it would look something like this:
The data is sent because I can see it by downloading the excel but not graphed. Do you know if it is possible to send them all together and graph them?
Thanks thingspeak MATLAB Answers — New Questions
why the curve in preview box not same as the original one ?
Post Content Post Content grabit MATLAB Answers — New Questions
Unrecognized function or variable splitAnomalyData Matlab 2023a
Hi, when running this demo
DetectPillImageAnomaliesUsingExplainableFCDDExample
using e.g. this code to open the live script
openExample(‘images_deeplearning/DetectPillImageAnomaliesUsingExplainableFCDDExample’)
I get the error
Unrecognized function or variable splitAnomalyData
I’ve tried the demo on both my local installation of Matlab 2023a and Matlab online. I get the same error. I have tried searching for the file splitAnomalyData using the operating system but it cannot find a file with that name. Oddly, if I type ‘help splitAnomalyData’ I get a response at the command line implying something is found.
Is the file missing or am I doing something wrong? Any guidance would be appreciated, thanks.Hi, when running this demo
DetectPillImageAnomaliesUsingExplainableFCDDExample
using e.g. this code to open the live script
openExample(‘images_deeplearning/DetectPillImageAnomaliesUsingExplainableFCDDExample’)
I get the error
Unrecognized function or variable splitAnomalyData
I’ve tried the demo on both my local installation of Matlab 2023a and Matlab online. I get the same error. I have tried searching for the file splitAnomalyData using the operating system but it cannot find a file with that name. Oddly, if I type ‘help splitAnomalyData’ I get a response at the command line implying something is found.
Is the file missing or am I doing something wrong? Any guidance would be appreciated, thanks. Hi, when running this demo
DetectPillImageAnomaliesUsingExplainableFCDDExample
using e.g. this code to open the live script
openExample(‘images_deeplearning/DetectPillImageAnomaliesUsingExplainableFCDDExample’)
I get the error
Unrecognized function or variable splitAnomalyData
I’ve tried the demo on both my local installation of Matlab 2023a and Matlab online. I get the same error. I have tried searching for the file splitAnomalyData using the operating system but it cannot find a file with that name. Oddly, if I type ‘help splitAnomalyData’ I get a response at the command line implying something is found.
Is the file missing or am I doing something wrong? Any guidance would be appreciated, thanks. unrecognized function MATLAB Answers — New Questions
how to train YOLOv8 using MATLAB?
Greetings everyone,
Ultralytics has released the latest pre-trained YOLOv8 network as a .mat file on GitHub. I am interested in retraining it using my own data. I would like to know how to modify aspects such as the feature-extracting layer, and how to add or remove layers to adjust image size. Until now, with YOLOx, there were functions available in MATLAB for handling the pre-trained network, but for YOLOv8, I am unsure how to proceed.
Any guidance would be greatly appreciated.
Thank youGreetings everyone,
Ultralytics has released the latest pre-trained YOLOv8 network as a .mat file on GitHub. I am interested in retraining it using my own data. I would like to know how to modify aspects such as the feature-extracting layer, and how to add or remove layers to adjust image size. Until now, with YOLOx, there were functions available in MATLAB for handling the pre-trained network, but for YOLOv8, I am unsure how to proceed.
Any guidance would be greatly appreciated.
Thank you Greetings everyone,
Ultralytics has released the latest pre-trained YOLOv8 network as a .mat file on GitHub. I am interested in retraining it using my own data. I would like to know how to modify aspects such as the feature-extracting layer, and how to add or remove layers to adjust image size. Until now, with YOLOx, there were functions available in MATLAB for handling the pre-trained network, but for YOLOv8, I am unsure how to proceed.
Any guidance would be greatly appreciated.
Thank you https://github.com/matlab-deep-learning/pretrained, https://github.com/ultralytics/ultralytics MATLAB Answers — New Questions
How to set my simulation powergui into continuous mode?
My LLC converter simulation is running well when set the powerGUI into discrete mode but have error when shift it into continous mode.
The error is:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘LLC_DualCtrl/powergui/EquivalentModel1/State-Space’ at time 0.013000000000000001 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
How to fix this error, the input voltage seems be infinite.My LLC converter simulation is running well when set the powerGUI into discrete mode but have error when shift it into continous mode.
The error is:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘LLC_DualCtrl/powergui/EquivalentModel1/State-Space’ at time 0.013000000000000001 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
How to fix this error, the input voltage seems be infinite. My LLC converter simulation is running well when set the powerGUI into discrete mode but have error when shift it into continous mode.
The error is:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘LLC_DualCtrl/powergui/EquivalentModel1/State-Space’ at time 0.013000000000000001 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
How to fix this error, the input voltage seems be infinite. simulink, simulation, power_conversion_control MATLAB Answers — New Questions
What is the critical gain and critical period in twin rotor MIMO system? How to calculate critical gain in twin rotor MIMO system?
For using fuzzy gain scheduling, we want to find the Kpmin and Kp max, in that, we didn’t find and calculate the critical gain and critical period in twin rotor MIMO system.Kindly help me to solve my doubt.For using fuzzy gain scheduling, we want to find the Kpmin and Kp max, in that, we didn’t find and calculate the critical gain and critical period in twin rotor MIMO system.Kindly help me to solve my doubt. For using fuzzy gain scheduling, we want to find the Kpmin and Kp max, in that, we didn’t find and calculate the critical gain and critical period in twin rotor MIMO system.Kindly help me to solve my doubt. #fuzzy logic, twin rotor mimo system, fuzzy gain scheduling MATLAB Answers — New Questions
How to fix the” reshape “error to convert a mat dataset file to an input image dataset file for convolutional neural network training?
My dataset includes data with 2816 x 2500 doubles, label pose with 2816 x 1, label person with 2816 x 1, label dataset with 2816 x 1, and POSE with 7 x 1 cells. i want to use this dataset in image format for training the CNN.so i should convert it into an image dataset for using in input . i said that to chat gpt and it gives me this code:
% Load the .mat file
data = load(‘file1.mat’);
% Extract the components from the loaded file
data_matrix = data.data; % 2816 x 2500 matrix
pose_labels = data.label_pose; % 2816 x 1 vector
person_labels = data.label_person; % 2816 x 1 vector
dataset_labels = data.label_dataset; % 2816 x 1 vector
POSE = data.POSE; % 7 x 1 cell array
% Define the desired image size
imageSize = [229, 229]; % Set your desired image size
% Reshape the data matrix into images
numImages = size(data_matrix, 1);
images = cell(numImages, 1);
for i = 1:numImages
image = reshape(data_matrix(i, :), imageSize);
images{i} = mat2gray(image); % Normalize pixel values to range [0, 1]
end
% Save the images as PNG files
outputFolder = ‘output_images’; % Set your desired output folder
if ~exist(outputFolder, ‘dir’)
mkdir(outputFolder);
end
for i = 1:numImages
imwrite(images{i}, fullfile(outputFolder, [‘image_’ num2str(i) ‘.png’]));
end
now i have this error:Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
how can i fix it ?My dataset includes data with 2816 x 2500 doubles, label pose with 2816 x 1, label person with 2816 x 1, label dataset with 2816 x 1, and POSE with 7 x 1 cells. i want to use this dataset in image format for training the CNN.so i should convert it into an image dataset for using in input . i said that to chat gpt and it gives me this code:
% Load the .mat file
data = load(‘file1.mat’);
% Extract the components from the loaded file
data_matrix = data.data; % 2816 x 2500 matrix
pose_labels = data.label_pose; % 2816 x 1 vector
person_labels = data.label_person; % 2816 x 1 vector
dataset_labels = data.label_dataset; % 2816 x 1 vector
POSE = data.POSE; % 7 x 1 cell array
% Define the desired image size
imageSize = [229, 229]; % Set your desired image size
% Reshape the data matrix into images
numImages = size(data_matrix, 1);
images = cell(numImages, 1);
for i = 1:numImages
image = reshape(data_matrix(i, :), imageSize);
images{i} = mat2gray(image); % Normalize pixel values to range [0, 1]
end
% Save the images as PNG files
outputFolder = ‘output_images’; % Set your desired output folder
if ~exist(outputFolder, ‘dir’)
mkdir(outputFolder);
end
for i = 1:numImages
imwrite(images{i}, fullfile(outputFolder, [‘image_’ num2str(i) ‘.png’]));
end
now i have this error:Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
how can i fix it ? My dataset includes data with 2816 x 2500 doubles, label pose with 2816 x 1, label person with 2816 x 1, label dataset with 2816 x 1, and POSE with 7 x 1 cells. i want to use this dataset in image format for training the CNN.so i should convert it into an image dataset for using in input . i said that to chat gpt and it gives me this code:
% Load the .mat file
data = load(‘file1.mat’);
% Extract the components from the loaded file
data_matrix = data.data; % 2816 x 2500 matrix
pose_labels = data.label_pose; % 2816 x 1 vector
person_labels = data.label_person; % 2816 x 1 vector
dataset_labels = data.label_dataset; % 2816 x 1 vector
POSE = data.POSE; % 7 x 1 cell array
% Define the desired image size
imageSize = [229, 229]; % Set your desired image size
% Reshape the data matrix into images
numImages = size(data_matrix, 1);
images = cell(numImages, 1);
for i = 1:numImages
image = reshape(data_matrix(i, :), imageSize);
images{i} = mat2gray(image); % Normalize pixel values to range [0, 1]
end
% Save the images as PNG files
outputFolder = ‘output_images’; % Set your desired output folder
if ~exist(outputFolder, ‘dir’)
mkdir(outputFolder);
end
for i = 1:numImages
imwrite(images{i}, fullfile(outputFolder, [‘image_’ num2str(i) ‘.png’]));
end
now i have this error:Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
how can i fix it ? reshape, dataset, mat file MATLAB Answers — New Questions
I am new to matlab and I’m trying to filter the noise out of the audio. I tried some filters but can’t event get close to lessening the noise.
I have the noisy file and the original file here https://drive.google.com/drive/folders/1zS5vHxFSzEpcwY_6KSBibLYUk0g2p36i?usp=sharingI have the noisy file and the original file here https://drive.google.com/drive/folders/1zS5vHxFSzEpcwY_6KSBibLYUk0g2p36i?usp=sharing I have the noisy file and the original file here https://drive.google.com/drive/folders/1zS5vHxFSzEpcwY_6KSBibLYUk0g2p36i?usp=sharing filter, audio MATLAB Answers — New Questions
Working with time-series data in a Matlab Function in Simulink
Hi,
I’ve collected several data from 2 sensors outside Matlab enrivonment, i’ve loaded them in a Matlab file through a load operation once they were stored in a .mat file. Let’s call these two arrays "a" and "b". The sensors collected 18000 data each, working 30 mins, this means they have collected 10 values per second. I have converted the arrays in time-series using those lines:
Ts=0.1; %sampling time
timevals=[0:Ts:1799];
a_=timeseries(a,timevals);
b_=timeseries(b,timevals);
Then, i’ve uploaded them in Simulink through two "from workspace" blocks, i’ve computed their difference, let’s call it "error" and then i have to work with a dynamic PI controller, this means that after the sum block that i used to compute the difference, there are two branches where this difference, the error, enters. I just have to implement a very simple function (my idea is to use two different Matlab Function Blocks, one for each branch), if the error is bigger than a quantity, the proportional action will lead to y=error*Kp, if the error is smaller or equal than this quantity, the action is y=error*Kp/100. Same for integral action. This sees to be an easy task but once i try, i get so many errors that i don’t know from which one i should begin… the question is: how to deal with time series inside a Matlab Function block? I’m thinking there is a conceptual error i perform, so i’m looking for some advice. This would be very appreciated, thanks!!
Some of the errors I get:
1) Errors occurred during parsing of MATLAB function ‘MATLAB Function1’
2) Undefined function or variable ‘Kp’ -> i’ve definied it both in worspace and in matlab function but i continue getting this error…
3) Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
4) Undefined function or variable ‘y’. The first assignment to a local variable determines its class.
PS. I’ve also computed the two results easily in Matlab, getting the two arrays y and y1 (for proportional part and integral part). Could it be good to convert them in time-series and plug them in the Simulink model? In this way i will avoid performing the function in Simulink, but in this case i only find input time-series block, so i don’t know how to put them in the middle of a simulink model. Simulink is really needed so I can’t avoid it and just writing a Matlab script because the future operations are related to integrators and rate limiters that would be very complex without Simulink…Hi,
I’ve collected several data from 2 sensors outside Matlab enrivonment, i’ve loaded them in a Matlab file through a load operation once they were stored in a .mat file. Let’s call these two arrays "a" and "b". The sensors collected 18000 data each, working 30 mins, this means they have collected 10 values per second. I have converted the arrays in time-series using those lines:
Ts=0.1; %sampling time
timevals=[0:Ts:1799];
a_=timeseries(a,timevals);
b_=timeseries(b,timevals);
Then, i’ve uploaded them in Simulink through two "from workspace" blocks, i’ve computed their difference, let’s call it "error" and then i have to work with a dynamic PI controller, this means that after the sum block that i used to compute the difference, there are two branches where this difference, the error, enters. I just have to implement a very simple function (my idea is to use two different Matlab Function Blocks, one for each branch), if the error is bigger than a quantity, the proportional action will lead to y=error*Kp, if the error is smaller or equal than this quantity, the action is y=error*Kp/100. Same for integral action. This sees to be an easy task but once i try, i get so many errors that i don’t know from which one i should begin… the question is: how to deal with time series inside a Matlab Function block? I’m thinking there is a conceptual error i perform, so i’m looking for some advice. This would be very appreciated, thanks!!
Some of the errors I get:
1) Errors occurred during parsing of MATLAB function ‘MATLAB Function1’
2) Undefined function or variable ‘Kp’ -> i’ve definied it both in worspace and in matlab function but i continue getting this error…
3) Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
4) Undefined function or variable ‘y’. The first assignment to a local variable determines its class.
PS. I’ve also computed the two results easily in Matlab, getting the two arrays y and y1 (for proportional part and integral part). Could it be good to convert them in time-series and plug them in the Simulink model? In this way i will avoid performing the function in Simulink, but in this case i only find input time-series block, so i don’t know how to put them in the middle of a simulink model. Simulink is really needed so I can’t avoid it and just writing a Matlab script because the future operations are related to integrators and rate limiters that would be very complex without Simulink… Hi,
I’ve collected several data from 2 sensors outside Matlab enrivonment, i’ve loaded them in a Matlab file through a load operation once they were stored in a .mat file. Let’s call these two arrays "a" and "b". The sensors collected 18000 data each, working 30 mins, this means they have collected 10 values per second. I have converted the arrays in time-series using those lines:
Ts=0.1; %sampling time
timevals=[0:Ts:1799];
a_=timeseries(a,timevals);
b_=timeseries(b,timevals);
Then, i’ve uploaded them in Simulink through two "from workspace" blocks, i’ve computed their difference, let’s call it "error" and then i have to work with a dynamic PI controller, this means that after the sum block that i used to compute the difference, there are two branches where this difference, the error, enters. I just have to implement a very simple function (my idea is to use two different Matlab Function Blocks, one for each branch), if the error is bigger than a quantity, the proportional action will lead to y=error*Kp, if the error is smaller or equal than this quantity, the action is y=error*Kp/100. Same for integral action. This sees to be an easy task but once i try, i get so many errors that i don’t know from which one i should begin… the question is: how to deal with time series inside a Matlab Function block? I’m thinking there is a conceptual error i perform, so i’m looking for some advice. This would be very appreciated, thanks!!
Some of the errors I get:
1) Errors occurred during parsing of MATLAB function ‘MATLAB Function1’
2) Undefined function or variable ‘Kp’ -> i’ve definied it both in worspace and in matlab function but i continue getting this error…
3) Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
4) Undefined function or variable ‘y’. The first assignment to a local variable determines its class.
PS. I’ve also computed the two results easily in Matlab, getting the two arrays y and y1 (for proportional part and integral part). Could it be good to convert them in time-series and plug them in the Simulink model? In this way i will avoid performing the function in Simulink, but in this case i only find input time-series block, so i don’t know how to put them in the middle of a simulink model. Simulink is really needed so I can’t avoid it and just writing a Matlab script because the future operations are related to integrators and rate limiters that would be very complex without Simulink… time series, matlab function, simulink MATLAB Answers — New Questions
how to writefile string as a text-file with function
hi guys, im trying to create files containing text which i defined by variable (see line 87).
i found error like this :
the current result :
it is supposed to be :
HERE I GIVE MY CODE :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
idx = unique(Zbotbeam(:).’);
Zbottombeam{ijk,:} = idx;
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
Zbottombeam{ijk} = table((1:numel(Zbottombeam{ijk,:}))’,Zbottombeam{ijk,:}’,’VariableNames’,{‘VariantID’,’Z Bottom Beam’});
Zbottombeam = Zbottombeam(VariantIDPassed);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Name the Frame
% top ordinary segment (TOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H*Ns),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew1{i,1})-1
jointI(j) = jointTOSnew1{i,1}.ID(j);
jointJ(j) = jointTOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(framecolumn{i,1}.("Frame ID"));
frameTOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS1{i,1}(median(1:height(frameTOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew2{i,1})-1
jointI(j) = jointTOSnew2{i,1}.ID(j);
jointJ(j) = jointTOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS1{i,1}.("Frame ID"));
frameTOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS2{i,1}(median(1:height(frameTOS2{i,1})),:) = [];
end
frameTOS = cellfun(@(varargin)vertcat(varargin{:}),frameTOS1,frameTOS2,’UniformOutput’,false);
%% Name the Frame
% bottom ordinary segment (BOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endBOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i}.Z),:);
jointBOS{i,:} = vertcat(jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i},endBOS{i});
jointBOSnew1{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(1)),:),2);
jointBOSnew2{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(2)),:),2);
jointBOSnew{i,:} = vertcat(jointBOSnew1{i},jointBOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBOSnew1{i,1})-1
jointI(j) = jointBOSnew1{i,1}.ID(j);
jointJ(j) = jointBOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS{i,1}.("Frame ID"));
frameBOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS1{i,1}(median(1:height(frameBOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ =0;
for j = 1:height(jointBOSnew2{i,1})-1
jointI(j) = jointBOSnew2{i,1}.ID(j);
jointJ(j) = jointBOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS1{i,1}.("Frame ID"));
frameBOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS2{i,1}(median(1:height(frameBOS2{i,1})),:) = [];
end
frameBOS = cellfun(@(varargin)vertcat(varargin{:}),frameBOS1,frameBOS2,’UniformOutput’,false);
%% Name the Frame
% top special segment (TSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointTSSnew1{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H),:),2);
jointTSSnew2{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H*Ns),:),2);
jointTSSnew{i,:} = vertcat(jointTSSnew1{i},jointTSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew1{i,1})-1
jointI(j) = jointTSSnew1{i,1}.ID(j);
jointJ(j) = jointTSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS{i,1}.("Frame ID"));
frameTSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew2{i,1})-1
jointI(j) = jointTSSnew2{i,1}.ID(j);
jointJ(j) = jointTSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS1{i,1}.("Frame ID"));
frameTSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameTSS = cellfun(@(varargin)vertcat(varargin{:}),frameTSS1,frameTSS2,’UniformOutput’,false);
%% Name the Frame
% bottom special segment (BSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointBSSnew1{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(1)),:),2);
jointBSSnew2{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(2)),:),2);
jointBSSnew{i,:} = vertcat(jointBSSnew1{i},jointBSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew1{i,1})-1
jointI(j) = jointBSSnew1{i,1}.ID(j);
jointJ(j) = jointBSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS{i,1}.("Frame ID"));
frameBSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew2{i,1})-1
jointI(j) = jointBSSnew2{i,1}.ID(j);
jointJ(j) = jointBSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBSS1{i,1}.("Frame ID"));
frameBSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameBSS = cellfun(@(varargin)vertcat(varargin{:}),frameBSS1,frameBSS2,’UniformOutput’,false);
%% Name the Frame
% diagonal ordinary segment (DOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tosleft{i,:} = frameTOS{i,1}(1:2:end,:);
tosright{i,:} = frameTOS{i,1}(2:2:end,:);
bosleft{i,:} = frameBOS{i,1}(1:2:end,:);
bosright{i,:} = frameBOS{i,1}(2:2:end,:);
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tosleft{i,1})
jointI(j) = tosleft{i,1}.JointI(j);
jointJ(j) = bosleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameBSS{i,1}.("Frame ID"));
frameDOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bosright{i,1})
jointI(j) = bosright{i,1}.JointI(j);
jointJ(j) = tosright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS1{i,1}.("Frame ID"));
frameDOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDOS = cellfun(@(varargin)vertcat(varargin{:}),frameDOS1,frameDOS2,’UniformOutput’,false);
%% Name the Frame
% diagonal special segment (DSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
tssright{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
bssright{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS{i,1}.("Frame ID"));
frameDSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bssright{i,1})
jointI(j) = bssright{i,1}.JointI(j);
jointJ(j) = tssright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDSS1{i,1}.("Frame ID"));
frameDSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDSS = cellfun(@(varargin)vertcat(varargin{:}),frameDSS1,frameDSS2,’UniformOutput’,false);
%% Name the Frame
% vertical special segment (VSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointI(j);
end
lastframenumber{i,:} = max(frameDSS{i,1}.("Frame ID"));
frameVSS{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Print ‘frame’ data to textline
txtframeCOLUMN = strings(height(framecolumn),1);
for i = 1:height(framecolumn)
T = framecolumn{i};
M = T{:,:};
txtframeCOLUMN(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTOS = strings(height(frameTOS),1);
for i = 1:height(frameTOS)
T = frameTOS{i};
M = T{:,:};
txtframeTOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBOS = strings(height(frameBOS),1);
for i = 1:height(frameBOS)
T = frameBOS{i};
M = T{:,:};
txtframeBOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTSS = strings(height(frameTSS),1);
for i = 1:height(frameTSS)
T = frameTSS{i};
M = T{:,:};
txtframeTSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBSS = strings(height(frameBSS),1);
for i = 1:height(frameBSS)
T = frameBSS{i};
M = T{:,:};
txtframeBSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDOS = strings(height(frameDOS),1);
for i = 1:height(frameDOS)
T = frameDOS{i};
M = T{:,:};
txtframeDOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDSS = strings(height(frameDSS),1);
for i = 1:height(frameDSS)
T = frameDSS{i};
M = T{:,:};
txtframeDSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeVSS = strings(height(frameVSS),1);
for i = 1:height(frameVSS)
T = frameVSS{i};
M = T{:,:};
txtframeVSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
%% Print ‘joint’ data to textline
txtjointBASE = strings(height(jointbase),1);
for i = 1:height(jointbase)
T = jointbase.("Joint Base"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBASE(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointCOLUMN = strings(height(jointcolumn),1);
for i = 1:height(jointcolumn)
T = jointcolumn.("Joint Column"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointCOLUMN(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTOS = strings(height(jointtopordinarysegment),1);
for i = 1:height(jointtopordinarysegment)
T = jointtopordinarysegment.("Joint Top Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBOS = strings(height(jointbottomordinarysegment),1);
for i = 1:height(jointbottomordinarysegment)
T = jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTSS = strings(height(jointtopspecialsegment),1);
for i = 1:height(jointtopspecialsegment)
T = jointtopspecialsegment.("Joint Top Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBSS = strings(height(jointbottomspecialsegment),1);
for i = 1:height(jointbottomspecialsegment)
T = jointbottomspecialsegment.("Joint Bottom Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
%% WRITE s2k Extension Files
VariantModel = compose(‘%d’, 1:height(VariantIDPassed));
lined= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
for i = 1:numel(VariantModel)
writefile(VariantModel{i},txtjointBASE{i},txtjointCOLUMN{i},txtjointTOS{i},txtjointBOS{i},txtjointTSS{i},txtjointBSS{i},txtframeCOLUMN{i},txtframeTOS{i},txtframeBOS{i},txtframeTSS{i},txtframeBSS{i},txtframeDOS{i},txtframeDSS{i},txtframeVSS{i});
end
files = dir(‘*.s2k’);
files(:).name;
function writefile(C,txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS,txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS)
fido = fopen("ModelVariant"+C+".s2k",’wt’);
newline = ‘n’;
line1=’File D:MAGISTERKULIAHTESISS2K FILEModelVariant-%d.s2k was saved on m/d/yy at h:mm:ss’;
line2=’TABLE: "PROGRAM CONTROL"’;
line3=’ ProgramName=SAP2000 Version=25.0.0 ProgLevel=Ultimate LicenseNum=3010*1D6KZBK478DMQCT LicenseOS=Yes LicenseSC=Yes LicenseHT=No CurrUnits="KN, m, C" SteelCode="AISC 360-10" ConcCode="ACI 318-19" AlumCode="AA 2015" _’;
line4=’ ColdCode=AISI-16 RegenHinge=Yes’;
line5=’TABLE: "ACTIVE DEGREES OF FREEDOM"’;
line6=’ UX=Yes UY=No UZ=Yes RX=No RY=Yes RZ=No’;
line7=’TABLE: "ANALYSIS OPTIONS"’;
line8=’ Solver=Multithreaded SolverProc="Analysis Process" NumParallel=0 Force32Bit=No StiffCase=None GeomMod=None HingeOpt="In Elements" NumAThreads=0 MaxFileSize=0 NumDThreads=0 NumRThreads=0 _ UseMMFiles="Program Determined" AllowDiff=No’;
line9=’TABLE: "COORDINATE SYSTEMS"’;
line10=’ Name=GLOBAL Type=Cartesian X=0 Y=0 Z=0 AboutZ=0 AboutY=0 AboutX=0′;
line11=’TABLE: "GRID LINES"’;
line12=’ CoordSys=GLOBAL AxisDir=X GridID=A XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End AllVisible=Yes BubbleSize=1,5′;
line13=’ CoordSys=GLOBAL AxisDir=X GridID=B XRYZCoord=15 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line14=’ CoordSys=GLOBAL AxisDir=X GridID=C XRYZCoord=30 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line15=’ CoordSys=GLOBAL AxisDir=Y GridID=1 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=Start’;
line16=’ CoordSys=GLOBAL AxisDir=Z GridID=Z0 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line17=’ CoordSys=GLOBAL AxisDir=Z GridID=Z1 XRYZCoord=5 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line18=’ CoordSys=GLOBAL AxisDir=Z GridID=Z2 XRYZCoord=10 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line19=’TABLE: "MATERIAL PROPERTIES 01 – GENERAL"’;
line20=’ Material=4000Psi Type=Concrete Grade="’ + "f’c 4000 " + ‘psi"’+ ‘ SymType=Isotropic TempDepend=No Color=Green GUID=b0920fc0-a39b-46e4-a096-037f0f0739a7 Notes="Customary ‘+"f’c 4000 psi "+’01/02/2024 20:13:33"’;
line21=’ Material=BJ-37 Type=Steel Grade="Grade 50" SymType=Isotropic TempDepend=No Color=Magenta Notes="ASTM A992 Grade 50 01/02/2024 20:03:34"’;
line22=’TABLE: "MATERIAL PROPERTIES 02 – BASIC MECHANICAL PROPERTIES"’;
line23=’ Material=4000Psi UnitWeight=23,5631216161854 UnitMass=2,40276960558926 E1=24855578,0600518 G12=10356490,8583549 U12=0,2 A1=9,89999952793124E-06′;
line24=’ Material=BJ-37 UnitWeight=76,9728639422648 UnitMass=7,84904737995992 E1=199947978,795958 G12=76903068,7676762 U12=0,3 A1=1,16999994421006E-05′;
line25=’TABLE: "MATERIAL PROPERTIES 03A – STEEL DATA"’;
line26=’ Material=BJ-37 Fy=235000 Fu=352500 EffFy=235000 EffFu=352500 SSCurveOpt=Simple SSHysType=Kinematic SHard=0,015 SMax=0,11 SRup=0,17 FinalSlope=-0,1 CoupModType="Von Mises"’;
line27=’TABLE: "MATERIAL PROPERTIES 06 – DAMPING PARAMETERS"’;
line28=’ Material=4000Psi ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line29=’ Material=BJ-37 ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line30=’TABLE: "MATERIAL PROPERTIES 09 – ACCEPTANCE CRITERIA"’;
line31=’ Material=4000Psi IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,003 LSComp=-0,006 CPComp=-0,015 IgnoreTens=Yes’;
line32=’ Material=BJ-37 IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,005 LSComp=-0,01 CPComp=-0,02′;
line33=’TABLE: "FRAME SECTION PROPERTIES 01 – GENERAL"’;
line34=’ SectionName=ExampleWideFlanged Material=BJ-37 Shape="I/Wide Flange" t3=0,25 t2=0,15 tf=0,012 tw=0,008 t2b=0,15 tfb=0,012 FilletRadius=0,012 Area=0,005552 TorsConst=2,13418666666667E-07 I33=6,04638656154112E-05 _’;
line35=’ I22=6,76749435145855E-06 I23=-6,7762635780344E-21 AS2=0,00200790111881035 AS3=0,00357344416053972 S33Top=0,00048371092492329 S33Bot=0,00048371092492329 S22Left=9,02332580194473E-05 S22Right=9,02332580194473E-05 _’;
line36=’ Z33=0,000546402338734841 Z22=0,00013961366126516 R33=0,10435739412628 R22=0,0349131651083826 CGOffset3=-1,38777878078145E-17 CGOffset2=5,55111512312578E-17 EccV2=0 EccV3=0 Cw=9,558675E-08 ConcCol=No ConcBeam=No _’;
line37=’ Color=Blue TotalWt=60,3707599671425 TotalMass=6,15610399662034 FromFile=No AMod=1 A2Mod=1 A3Mod=1 JMod=1 I2Mod=1 I3Mod=1 MMod=1 WMod=1 Notes="Added 03/04/2024 20:08:55′;
line38=’TABLE: "LOAD PATTERN DEFINITIONS"’;
line39=’ LoadPat=DEAD DesignType=Dead SelfWtMult=1 GUID=d2c74fc0-a771-416d-b3dc-4b0a2047268d’;
line40=’ LoadPat=SUPERDEAD DesignType="Super Dead" SelfWtMult=0 GUID=91534b51-672f-4fb0-a037-d7225de00c69 Notes="Added 01/02/2024 20:08:11"’;
line41=’ LoadPat=LIVE DesignType=Live SelfWtMult=0 GUID=1f6f6fd1-e0f1-4fcb-bf3d-dc86bd53f1a8 Notes="Added 01/02/2024 20:08:16"’;
line42=’TABLE: "GROUPS 1 – DEFINITIONS"’;
line43=’ GroupName=All Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line44=’ GroupName=ST_Top Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line45=’ GroupName=ST_Bot Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line46=’ GroupName=ST_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line47=’ GroupName=ST_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line48=’ GroupName=OT_Top1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line49=’ GroupName=OT_Top2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Yellow’;
line49a=’ GroupName=OT_Bot1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line49b=’ GroupName=OT_Bot2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line49c=’ GroupName=OT_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line49d=’ GroupName=OT_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line49e=’ GroupName=Column_End Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line50=’TABLE: "JOINT PATTERN DEFINITIONS"’;
line51=’ Pattern=Default’;
line52=’TABLE: "MASS SOURCE"’;
line53=’ MassSource=MSSSRC1 Elements=Yes Masses=Yes Loads=Yes IsDefault=Yes LoadPat=DEAD Multiplier=1′;
line54=’ MassSource=MSSSRC1 LoadPat=SUPERDEAD Multiplier=1′;
line55=’ MassSource=MSSSRC1 LoadPat=LIVE Multiplier=0,5′;
line56=’TABLE: "LOAD CASE DEFINITIONS"’;
line57=’ Case=DEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=91b91585-f6e6-446e-ac30-362013fd8af9′;
line58=’ Case=MODAL Type=LinModal InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Other DesActOpt="Prog Det" DesignAct=Other AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=3e160405-efbf-45fb-ae06-c6da634ca183′;
line59=’ Case=SUPERDEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType="Super Dead" DesActOpt="Prog Det" DesignAct="Long-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=2ca565b7-af73-42e9-9208-0a0739594699′;
line60=’ Case=LIVE Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Live DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e969dd8f-56cc-40d7-af8a-0fba39157fcb’;
line61=’ Case="Gravity NLS" Type=NonStatic InitialCond=Zero MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line62=’ Case=Pushover-UX Type=NonStatic InitialCond="Gravity NLS" MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Quake DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line63=’TABLE: "CASE – STATIC 1 – LOAD ASSIGNMENTS"’;
line64=’ Case=DEAD LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line65=’ Case=SUPERDEAD LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line66=’ Case=LIVE LoadType="Load pattern" LoadName=LIVE LoadSF=1′;
line67=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line68=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line69=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=LIVE LoadSF=0,5′;
line70=’ Case=Pushover-UX LoadType=Accel LoadName="Accel UX" TransAccSF=-1′;
line71=’TABLE: "CASE – STATIC 2 – NONLINEAR LOAD APPLICATION"’;
line72=’ Case="Gravity NLS" LoadApp="Full Load" MonitorDOF=U1 MonitorJt=9′;
line73=’ Case=Pushover-UX LoadApp="Displ Ctrl" DisplType=Monitored TargetDispl=1 MonitorDOF=U1 MonitorJt=9′;
line74=’TABLE: "CASE – STATIC 4 – NONLINEAR PARAMETERS"’;
line75=’ Case="Gravity NLS" GeoNonLin=P-Delta ResultsSave="Final State" SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 _’;
line76=’ TFAccelFact=1 TFNoStop=No’;
line77=’ Case=Pushover-UX GeoNonLin=P-Delta ResultsSave="Multiple States" MinNumState=10 MaxNumState=100 PosIncOnly=Yes SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 _’;
line78=’ MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 TFAccelFact=1 TFNoStop=No’;
line79=’TABLE: "CASE – MODAL 1 – GENERAL"’;
line80=’ Case=MODAL ModeType=Eigen MaxNumModes=12 MinNumModes=1 EigenShift=0 EigenCutoff=0 EigenTol=1E-09 AutoShift=Yes’;
line81=’TABLE: "JOINT COORDINATES"’;
line82= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
line83=’TABLE: "CONNECTIVITY – FRAME"’;
line84= append(txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS);
line85=’TABLE: "END TABLE DATA"’;
combine1 = append(line1,newline,line2,newline,line3,newline,line4,newline,line5,newline,line6,newline,line7,newline,line8,newline,line9,newline,line10,newline,line11,newline,line12,newline,line13,newline,line14,newline,line15,newline,line16,newline,line17,newline,line18,newline,line19,newline,line20,newline,line21,newline,line22,newline,line23,newline,line24,newline,line25,newline,line26,newline,line27,newline,line28,newline,line29,newline,line30,newline,line31,newline,line32,newline,line33,newline,line34,newline,line35,newline,line36);
combine2 = append(combine1,newline,line37,newline,line38,newline,line39,newline,line40,newline,line41,newline,line42,newline,line43,newline,line44,newline,line45,newline,line46,newline,line47,newline,line48,newline,line49,newline,line49a,newline,line49b,newline,line49c,newline,line49d,newline,line49e,newline,line50,newline,line51,newline,line52,newline,line53,newline,line54,newline,line55,newline,line56,newline,line57,newline,line58,newline,line59,newline,line60,newline,line61,newline,line62,newline,line63,newline,line64,newline,line65,newline,line66,newline,line67,newline,line68,newline);
combine3 = append(combine2,line69,newline,line70,newline,line71,newline,line72,newline,line73,newline,line74,newline,line75,newline,line76,newline,line77,newline,line78,newline,line79,newline,line80,newline,line81,newline,line82,newline,line83,newline,line84,newline,line85);
fprintf(fido,combine3,C);
fclose(fido);
endhi guys, im trying to create files containing text which i defined by variable (see line 87).
i found error like this :
the current result :
it is supposed to be :
HERE I GIVE MY CODE :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
idx = unique(Zbotbeam(:).’);
Zbottombeam{ijk,:} = idx;
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
Zbottombeam{ijk} = table((1:numel(Zbottombeam{ijk,:}))’,Zbottombeam{ijk,:}’,’VariableNames’,{‘VariantID’,’Z Bottom Beam’});
Zbottombeam = Zbottombeam(VariantIDPassed);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Name the Frame
% top ordinary segment (TOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H*Ns),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew1{i,1})-1
jointI(j) = jointTOSnew1{i,1}.ID(j);
jointJ(j) = jointTOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(framecolumn{i,1}.("Frame ID"));
frameTOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS1{i,1}(median(1:height(frameTOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew2{i,1})-1
jointI(j) = jointTOSnew2{i,1}.ID(j);
jointJ(j) = jointTOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS1{i,1}.("Frame ID"));
frameTOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS2{i,1}(median(1:height(frameTOS2{i,1})),:) = [];
end
frameTOS = cellfun(@(varargin)vertcat(varargin{:}),frameTOS1,frameTOS2,’UniformOutput’,false);
%% Name the Frame
% bottom ordinary segment (BOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endBOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i}.Z),:);
jointBOS{i,:} = vertcat(jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i},endBOS{i});
jointBOSnew1{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(1)),:),2);
jointBOSnew2{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(2)),:),2);
jointBOSnew{i,:} = vertcat(jointBOSnew1{i},jointBOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBOSnew1{i,1})-1
jointI(j) = jointBOSnew1{i,1}.ID(j);
jointJ(j) = jointBOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS{i,1}.("Frame ID"));
frameBOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS1{i,1}(median(1:height(frameBOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ =0;
for j = 1:height(jointBOSnew2{i,1})-1
jointI(j) = jointBOSnew2{i,1}.ID(j);
jointJ(j) = jointBOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS1{i,1}.("Frame ID"));
frameBOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS2{i,1}(median(1:height(frameBOS2{i,1})),:) = [];
end
frameBOS = cellfun(@(varargin)vertcat(varargin{:}),frameBOS1,frameBOS2,’UniformOutput’,false);
%% Name the Frame
% top special segment (TSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointTSSnew1{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H),:),2);
jointTSSnew2{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H*Ns),:),2);
jointTSSnew{i,:} = vertcat(jointTSSnew1{i},jointTSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew1{i,1})-1
jointI(j) = jointTSSnew1{i,1}.ID(j);
jointJ(j) = jointTSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS{i,1}.("Frame ID"));
frameTSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew2{i,1})-1
jointI(j) = jointTSSnew2{i,1}.ID(j);
jointJ(j) = jointTSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS1{i,1}.("Frame ID"));
frameTSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameTSS = cellfun(@(varargin)vertcat(varargin{:}),frameTSS1,frameTSS2,’UniformOutput’,false);
%% Name the Frame
% bottom special segment (BSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointBSSnew1{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(1)),:),2);
jointBSSnew2{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(2)),:),2);
jointBSSnew{i,:} = vertcat(jointBSSnew1{i},jointBSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew1{i,1})-1
jointI(j) = jointBSSnew1{i,1}.ID(j);
jointJ(j) = jointBSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS{i,1}.("Frame ID"));
frameBSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew2{i,1})-1
jointI(j) = jointBSSnew2{i,1}.ID(j);
jointJ(j) = jointBSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBSS1{i,1}.("Frame ID"));
frameBSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameBSS = cellfun(@(varargin)vertcat(varargin{:}),frameBSS1,frameBSS2,’UniformOutput’,false);
%% Name the Frame
% diagonal ordinary segment (DOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tosleft{i,:} = frameTOS{i,1}(1:2:end,:);
tosright{i,:} = frameTOS{i,1}(2:2:end,:);
bosleft{i,:} = frameBOS{i,1}(1:2:end,:);
bosright{i,:} = frameBOS{i,1}(2:2:end,:);
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tosleft{i,1})
jointI(j) = tosleft{i,1}.JointI(j);
jointJ(j) = bosleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameBSS{i,1}.("Frame ID"));
frameDOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bosright{i,1})
jointI(j) = bosright{i,1}.JointI(j);
jointJ(j) = tosright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS1{i,1}.("Frame ID"));
frameDOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDOS = cellfun(@(varargin)vertcat(varargin{:}),frameDOS1,frameDOS2,’UniformOutput’,false);
%% Name the Frame
% diagonal special segment (DSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
tssright{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
bssright{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS{i,1}.("Frame ID"));
frameDSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bssright{i,1})
jointI(j) = bssright{i,1}.JointI(j);
jointJ(j) = tssright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDSS1{i,1}.("Frame ID"));
frameDSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDSS = cellfun(@(varargin)vertcat(varargin{:}),frameDSS1,frameDSS2,’UniformOutput’,false);
%% Name the Frame
% vertical special segment (VSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointI(j);
end
lastframenumber{i,:} = max(frameDSS{i,1}.("Frame ID"));
frameVSS{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Print ‘frame’ data to textline
txtframeCOLUMN = strings(height(framecolumn),1);
for i = 1:height(framecolumn)
T = framecolumn{i};
M = T{:,:};
txtframeCOLUMN(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTOS = strings(height(frameTOS),1);
for i = 1:height(frameTOS)
T = frameTOS{i};
M = T{:,:};
txtframeTOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBOS = strings(height(frameBOS),1);
for i = 1:height(frameBOS)
T = frameBOS{i};
M = T{:,:};
txtframeBOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTSS = strings(height(frameTSS),1);
for i = 1:height(frameTSS)
T = frameTSS{i};
M = T{:,:};
txtframeTSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBSS = strings(height(frameBSS),1);
for i = 1:height(frameBSS)
T = frameBSS{i};
M = T{:,:};
txtframeBSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDOS = strings(height(frameDOS),1);
for i = 1:height(frameDOS)
T = frameDOS{i};
M = T{:,:};
txtframeDOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDSS = strings(height(frameDSS),1);
for i = 1:height(frameDSS)
T = frameDSS{i};
M = T{:,:};
txtframeDSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeVSS = strings(height(frameVSS),1);
for i = 1:height(frameVSS)
T = frameVSS{i};
M = T{:,:};
txtframeVSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
%% Print ‘joint’ data to textline
txtjointBASE = strings(height(jointbase),1);
for i = 1:height(jointbase)
T = jointbase.("Joint Base"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBASE(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointCOLUMN = strings(height(jointcolumn),1);
for i = 1:height(jointcolumn)
T = jointcolumn.("Joint Column"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointCOLUMN(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTOS = strings(height(jointtopordinarysegment),1);
for i = 1:height(jointtopordinarysegment)
T = jointtopordinarysegment.("Joint Top Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBOS = strings(height(jointbottomordinarysegment),1);
for i = 1:height(jointbottomordinarysegment)
T = jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTSS = strings(height(jointtopspecialsegment),1);
for i = 1:height(jointtopspecialsegment)
T = jointtopspecialsegment.("Joint Top Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBSS = strings(height(jointbottomspecialsegment),1);
for i = 1:height(jointbottomspecialsegment)
T = jointbottomspecialsegment.("Joint Bottom Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
%% WRITE s2k Extension Files
VariantModel = compose(‘%d’, 1:height(VariantIDPassed));
lined= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
for i = 1:numel(VariantModel)
writefile(VariantModel{i},txtjointBASE{i},txtjointCOLUMN{i},txtjointTOS{i},txtjointBOS{i},txtjointTSS{i},txtjointBSS{i},txtframeCOLUMN{i},txtframeTOS{i},txtframeBOS{i},txtframeTSS{i},txtframeBSS{i},txtframeDOS{i},txtframeDSS{i},txtframeVSS{i});
end
files = dir(‘*.s2k’);
files(:).name;
function writefile(C,txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS,txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS)
fido = fopen("ModelVariant"+C+".s2k",’wt’);
newline = ‘n’;
line1=’File D:MAGISTERKULIAHTESISS2K FILEModelVariant-%d.s2k was saved on m/d/yy at h:mm:ss’;
line2=’TABLE: "PROGRAM CONTROL"’;
line3=’ ProgramName=SAP2000 Version=25.0.0 ProgLevel=Ultimate LicenseNum=3010*1D6KZBK478DMQCT LicenseOS=Yes LicenseSC=Yes LicenseHT=No CurrUnits="KN, m, C" SteelCode="AISC 360-10" ConcCode="ACI 318-19" AlumCode="AA 2015" _’;
line4=’ ColdCode=AISI-16 RegenHinge=Yes’;
line5=’TABLE: "ACTIVE DEGREES OF FREEDOM"’;
line6=’ UX=Yes UY=No UZ=Yes RX=No RY=Yes RZ=No’;
line7=’TABLE: "ANALYSIS OPTIONS"’;
line8=’ Solver=Multithreaded SolverProc="Analysis Process" NumParallel=0 Force32Bit=No StiffCase=None GeomMod=None HingeOpt="In Elements" NumAThreads=0 MaxFileSize=0 NumDThreads=0 NumRThreads=0 _ UseMMFiles="Program Determined" AllowDiff=No’;
line9=’TABLE: "COORDINATE SYSTEMS"’;
line10=’ Name=GLOBAL Type=Cartesian X=0 Y=0 Z=0 AboutZ=0 AboutY=0 AboutX=0′;
line11=’TABLE: "GRID LINES"’;
line12=’ CoordSys=GLOBAL AxisDir=X GridID=A XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End AllVisible=Yes BubbleSize=1,5′;
line13=’ CoordSys=GLOBAL AxisDir=X GridID=B XRYZCoord=15 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line14=’ CoordSys=GLOBAL AxisDir=X GridID=C XRYZCoord=30 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line15=’ CoordSys=GLOBAL AxisDir=Y GridID=1 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=Start’;
line16=’ CoordSys=GLOBAL AxisDir=Z GridID=Z0 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line17=’ CoordSys=GLOBAL AxisDir=Z GridID=Z1 XRYZCoord=5 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line18=’ CoordSys=GLOBAL AxisDir=Z GridID=Z2 XRYZCoord=10 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line19=’TABLE: "MATERIAL PROPERTIES 01 – GENERAL"’;
line20=’ Material=4000Psi Type=Concrete Grade="’ + "f’c 4000 " + ‘psi"’+ ‘ SymType=Isotropic TempDepend=No Color=Green GUID=b0920fc0-a39b-46e4-a096-037f0f0739a7 Notes="Customary ‘+"f’c 4000 psi "+’01/02/2024 20:13:33"’;
line21=’ Material=BJ-37 Type=Steel Grade="Grade 50" SymType=Isotropic TempDepend=No Color=Magenta Notes="ASTM A992 Grade 50 01/02/2024 20:03:34"’;
line22=’TABLE: "MATERIAL PROPERTIES 02 – BASIC MECHANICAL PROPERTIES"’;
line23=’ Material=4000Psi UnitWeight=23,5631216161854 UnitMass=2,40276960558926 E1=24855578,0600518 G12=10356490,8583549 U12=0,2 A1=9,89999952793124E-06′;
line24=’ Material=BJ-37 UnitWeight=76,9728639422648 UnitMass=7,84904737995992 E1=199947978,795958 G12=76903068,7676762 U12=0,3 A1=1,16999994421006E-05′;
line25=’TABLE: "MATERIAL PROPERTIES 03A – STEEL DATA"’;
line26=’ Material=BJ-37 Fy=235000 Fu=352500 EffFy=235000 EffFu=352500 SSCurveOpt=Simple SSHysType=Kinematic SHard=0,015 SMax=0,11 SRup=0,17 FinalSlope=-0,1 CoupModType="Von Mises"’;
line27=’TABLE: "MATERIAL PROPERTIES 06 – DAMPING PARAMETERS"’;
line28=’ Material=4000Psi ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line29=’ Material=BJ-37 ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line30=’TABLE: "MATERIAL PROPERTIES 09 – ACCEPTANCE CRITERIA"’;
line31=’ Material=4000Psi IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,003 LSComp=-0,006 CPComp=-0,015 IgnoreTens=Yes’;
line32=’ Material=BJ-37 IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,005 LSComp=-0,01 CPComp=-0,02′;
line33=’TABLE: "FRAME SECTION PROPERTIES 01 – GENERAL"’;
line34=’ SectionName=ExampleWideFlanged Material=BJ-37 Shape="I/Wide Flange" t3=0,25 t2=0,15 tf=0,012 tw=0,008 t2b=0,15 tfb=0,012 FilletRadius=0,012 Area=0,005552 TorsConst=2,13418666666667E-07 I33=6,04638656154112E-05 _’;
line35=’ I22=6,76749435145855E-06 I23=-6,7762635780344E-21 AS2=0,00200790111881035 AS3=0,00357344416053972 S33Top=0,00048371092492329 S33Bot=0,00048371092492329 S22Left=9,02332580194473E-05 S22Right=9,02332580194473E-05 _’;
line36=’ Z33=0,000546402338734841 Z22=0,00013961366126516 R33=0,10435739412628 R22=0,0349131651083826 CGOffset3=-1,38777878078145E-17 CGOffset2=5,55111512312578E-17 EccV2=0 EccV3=0 Cw=9,558675E-08 ConcCol=No ConcBeam=No _’;
line37=’ Color=Blue TotalWt=60,3707599671425 TotalMass=6,15610399662034 FromFile=No AMod=1 A2Mod=1 A3Mod=1 JMod=1 I2Mod=1 I3Mod=1 MMod=1 WMod=1 Notes="Added 03/04/2024 20:08:55′;
line38=’TABLE: "LOAD PATTERN DEFINITIONS"’;
line39=’ LoadPat=DEAD DesignType=Dead SelfWtMult=1 GUID=d2c74fc0-a771-416d-b3dc-4b0a2047268d’;
line40=’ LoadPat=SUPERDEAD DesignType="Super Dead" SelfWtMult=0 GUID=91534b51-672f-4fb0-a037-d7225de00c69 Notes="Added 01/02/2024 20:08:11"’;
line41=’ LoadPat=LIVE DesignType=Live SelfWtMult=0 GUID=1f6f6fd1-e0f1-4fcb-bf3d-dc86bd53f1a8 Notes="Added 01/02/2024 20:08:16"’;
line42=’TABLE: "GROUPS 1 – DEFINITIONS"’;
line43=’ GroupName=All Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line44=’ GroupName=ST_Top Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line45=’ GroupName=ST_Bot Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line46=’ GroupName=ST_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line47=’ GroupName=ST_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line48=’ GroupName=OT_Top1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line49=’ GroupName=OT_Top2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Yellow’;
line49a=’ GroupName=OT_Bot1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line49b=’ GroupName=OT_Bot2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line49c=’ GroupName=OT_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line49d=’ GroupName=OT_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line49e=’ GroupName=Column_End Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line50=’TABLE: "JOINT PATTERN DEFINITIONS"’;
line51=’ Pattern=Default’;
line52=’TABLE: "MASS SOURCE"’;
line53=’ MassSource=MSSSRC1 Elements=Yes Masses=Yes Loads=Yes IsDefault=Yes LoadPat=DEAD Multiplier=1′;
line54=’ MassSource=MSSSRC1 LoadPat=SUPERDEAD Multiplier=1′;
line55=’ MassSource=MSSSRC1 LoadPat=LIVE Multiplier=0,5′;
line56=’TABLE: "LOAD CASE DEFINITIONS"’;
line57=’ Case=DEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=91b91585-f6e6-446e-ac30-362013fd8af9′;
line58=’ Case=MODAL Type=LinModal InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Other DesActOpt="Prog Det" DesignAct=Other AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=3e160405-efbf-45fb-ae06-c6da634ca183′;
line59=’ Case=SUPERDEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType="Super Dead" DesActOpt="Prog Det" DesignAct="Long-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=2ca565b7-af73-42e9-9208-0a0739594699′;
line60=’ Case=LIVE Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Live DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e969dd8f-56cc-40d7-af8a-0fba39157fcb’;
line61=’ Case="Gravity NLS" Type=NonStatic InitialCond=Zero MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line62=’ Case=Pushover-UX Type=NonStatic InitialCond="Gravity NLS" MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Quake DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line63=’TABLE: "CASE – STATIC 1 – LOAD ASSIGNMENTS"’;
line64=’ Case=DEAD LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line65=’ Case=SUPERDEAD LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line66=’ Case=LIVE LoadType="Load pattern" LoadName=LIVE LoadSF=1′;
line67=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line68=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line69=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=LIVE LoadSF=0,5′;
line70=’ Case=Pushover-UX LoadType=Accel LoadName="Accel UX" TransAccSF=-1′;
line71=’TABLE: "CASE – STATIC 2 – NONLINEAR LOAD APPLICATION"’;
line72=’ Case="Gravity NLS" LoadApp="Full Load" MonitorDOF=U1 MonitorJt=9′;
line73=’ Case=Pushover-UX LoadApp="Displ Ctrl" DisplType=Monitored TargetDispl=1 MonitorDOF=U1 MonitorJt=9′;
line74=’TABLE: "CASE – STATIC 4 – NONLINEAR PARAMETERS"’;
line75=’ Case="Gravity NLS" GeoNonLin=P-Delta ResultsSave="Final State" SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 _’;
line76=’ TFAccelFact=1 TFNoStop=No’;
line77=’ Case=Pushover-UX GeoNonLin=P-Delta ResultsSave="Multiple States" MinNumState=10 MaxNumState=100 PosIncOnly=Yes SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 _’;
line78=’ MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 TFAccelFact=1 TFNoStop=No’;
line79=’TABLE: "CASE – MODAL 1 – GENERAL"’;
line80=’ Case=MODAL ModeType=Eigen MaxNumModes=12 MinNumModes=1 EigenShift=0 EigenCutoff=0 EigenTol=1E-09 AutoShift=Yes’;
line81=’TABLE: "JOINT COORDINATES"’;
line82= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
line83=’TABLE: "CONNECTIVITY – FRAME"’;
line84= append(txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS);
line85=’TABLE: "END TABLE DATA"’;
combine1 = append(line1,newline,line2,newline,line3,newline,line4,newline,line5,newline,line6,newline,line7,newline,line8,newline,line9,newline,line10,newline,line11,newline,line12,newline,line13,newline,line14,newline,line15,newline,line16,newline,line17,newline,line18,newline,line19,newline,line20,newline,line21,newline,line22,newline,line23,newline,line24,newline,line25,newline,line26,newline,line27,newline,line28,newline,line29,newline,line30,newline,line31,newline,line32,newline,line33,newline,line34,newline,line35,newline,line36);
combine2 = append(combine1,newline,line37,newline,line38,newline,line39,newline,line40,newline,line41,newline,line42,newline,line43,newline,line44,newline,line45,newline,line46,newline,line47,newline,line48,newline,line49,newline,line49a,newline,line49b,newline,line49c,newline,line49d,newline,line49e,newline,line50,newline,line51,newline,line52,newline,line53,newline,line54,newline,line55,newline,line56,newline,line57,newline,line58,newline,line59,newline,line60,newline,line61,newline,line62,newline,line63,newline,line64,newline,line65,newline,line66,newline,line67,newline,line68,newline);
combine3 = append(combine2,line69,newline,line70,newline,line71,newline,line72,newline,line73,newline,line74,newline,line75,newline,line76,newline,line77,newline,line78,newline,line79,newline,line80,newline,line81,newline,line82,newline,line83,newline,line84,newline,line85);
fprintf(fido,combine3,C);
fclose(fido);
end hi guys, im trying to create files containing text which i defined by variable (see line 87).
i found error like this :
the current result :
it is supposed to be :
HERE I GIVE MY CODE :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
% Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
% Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00];
% Variable3
Nss = [2,3,4];
% Definition
Var1HeightofTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
% % Xbase = zeros(1,length(Totalvariant));
% % Zbase = zeros(1,length(Totalvariant));
% % Xcol = zeros(1,length(Totalvariant));
% % Zcol = zeros(1,length(Totalvariant));
% % Xos = zeros(1,length(Totalvariant));
% % Zos = zeros(1,length(Totalvariant));
% % Xss = zeros(1,length(Totalvariant));
% % Zss = zeros(1,length(Totalvariant));
% % X = zeros(1,length(Totalvariant));
% % Z = zeros(1,length(Totalvariant));
% % jointbase = zeros(1,length(Totalvariant));
% % jointcolumn = zeros(1,length(Totalvariant));
% % jointordinarysegment = zeros(1,length(Totalvariant));
% % jointtopordinarysegment = zeros(1,length(Totalvariant));
% % jointbottomordinarysegment = zeros(1,length(Totalvariant));
% % jointspecialsegment = zeros(1,length(Totalvariant));
% % jointtopspecialsegment = zeros(1,length(Totalvariant));
% % jointbottomspecialsegment = zeros(1,length(Totalvariant));
ijk = 0;
for i = 1:numel(h)
for j = 1:numel(Lss)
for k = 1:numel(Nss)
ijk = ijk+1;
Variantmodel{ijk,:} = table(ijk,h(i),Lss(j),Nss(k),’VariableNames’,{‘VariantID’,’Height’,’Length’,’Number’});
%% Cooridinate Point Base(base)
Xbase{ijk,:} = L*(0:NumberBay);
Zbase{ijk,:} = repelem(0,1,length(Xbase{ijk,:}));
%% Column(col)
Xcolumn = L*(0:NumberBay);
Zcolumn = repelem(H*(1:NumberStory),1,length(Xcolumn));
Xbotbeam = L*(0:NumberBay);
Zbotbeam = repelem((H*(1:NumberStory)-h(i)),1,length(Xbotbeam));
idx = unique(Zbotbeam(:).’);
Zbottombeam{ijk,:} = idx;
% replicate [X] to be the same size as [Z] for plotting:
Xcol{ijk,:} = repmat([Xcolumn,Xbotbeam],1,NumberStory);
Zcol{ijk,:} = [Zcolumn,Zbotbeam];
%% Cooridinate Point Ordinary Segment (os)
% calculate span length of ordinary segment
Los = (L-Lss(j))/2;
Nos = Los/h(i);
Nos = round(Nos);
los = Los/Nos;
totalspan{ijk,:} = los*Nos*2+Lss(j);
if totalspan{ijk,:} == 15.000
checkspan{ijk,:} = "correct span";
else
checkspan{ijk,:} = "span must be 15m";
end
% top and bottom joint of ordinary segment(os)
XTopOrdinarySegment = reshape([los*(1:Nos),(L/2+Lss(j)/2)+los*(0:Nos-1)].’+L*(0:(NumberBay-1)),1,[]);
XBottomOrdinarySegment = XTopOrdinarySegment;
ZTopOrdinarySegment = repelem(H*(1:NumberStory),1,2*Nos*NumberBay);
ZBottomOrdinarySegment = repelem(H*(1:NumberStory)-h(i),1,2*Nos*NumberBay);
% replicate [X] to be the same size as [Z] for plotting:
Xos{ijk,:} = repmat([XTopOrdinarySegment,XBottomOrdinarySegment],1,NumberStory);
Zos{ijk,:} = [ZTopOrdinarySegment,ZBottomOrdinarySegment];
%% Cooridinate Point Special Segment (ss)
% calculate span length of special segment
lss = Lss(j)/Nss(k);
% top and bottom joint of special segment(ss)
XTopSpecialSegment = reshape((lss*(0:Nss(k))+L/2-Lss(j)/2).’+L*(0:(NumberBay-1)),1,[]);
XBottomSpecialSegment = XTopSpecialSegment;
ZTopSpecialSegment = repelem(H*(1:NumberStory),1,length(XTopSpecialSegment));
ZBottomSpecialSegment = repelem(H*(1:NumberStory)-h(i),1,length(XBottomSpecialSegment));
% replicate [X] to be the same size as [Z] for plotting:
Xss{ijk,:} = repmat([XTopSpecialSegment,XBottomSpecialSegment],1,NumberStory);
Zss{ijk,:} = [ZTopSpecialSegment,ZBottomSpecialSegment];
%% Plot Cooridinate Point (X,Z)
X{ijk,:} = [Xbase{ijk,:},Xcol{ijk,:},Xos{ijk,:},Xss{ijk,:}];
Z{ijk,:} = [Zbase{ijk,:},Zcol{ijk,:},Zos{ijk,:},Zss{ijk,:}];
scatter(X{ijk,:},Z{ijk,:},’filled’),grid on
%check angle
tangent = (Lss(j)/Nss(k))/h(i);
anglespecialsegment(ijk) = atand(tangent);
%% Name the Joint
jointbase{ijk} = table((1:numel(Xbase{ijk,:}))’,Xbase{ijk,:}’,Zbase{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointcolumn{ijk} = table((max(jointbase{ijk}.ID)+1:numel(Xcol{ijk,:})+max(jointbase{ijk}.ID))’,Xcol{ijk,:}’,Zcol{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointordinarysegment{ijk} = table((max(jointcolumn{ijk}.ID)+1:numel(Xos{ijk,:})+max(jointcolumn{ijk}.ID))’,Xos{ijk,:}’,Zos{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zcolumn),:);
jointbottomordinarysegment{ijk} = jointordinarysegment{ijk}(ismember(jointordinarysegment{ijk}.Z,Zbotbeam),:);
jointspecialsegment{ijk} = table((max(jointbottomordinarysegment{ijk}.ID)+1:numel(Xss{ijk,:})+max(jointbottomordinarysegment{ijk}.ID))’,Xss{ijk,:}’,Zss{ijk,:}’,’VariableNames’,{‘ID’,’X’,’Z’});
jointtopspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zcolumn),:);
jointbottomspecialsegment{ijk} = jointspecialsegment{ijk}(ismember(jointspecialsegment{ijk}.Z,Zbotbeam),:);
end
end
end
% Verify Variants Which Passed the Angle Requirement
tablecheck = table((1:numel(anglespecialsegment))’,totalspan,anglespecialsegment’,’VariableNames’,{‘VariantID’,’Total Span’,’Angle’});
VariantIDPassed = tablecheck.VariantID(tablecheck.Angle>=30 & tablecheck.Angle<=60);
jointbase = table((1:numel(jointbase))’,jointbase’,’VariableNames’,{‘VariantID’,’Joint Base’});
jointbase = jointbase(ismember(jointbase.VariantID,VariantIDPassed),:);
jointcolumn = table((1:numel(jointcolumn))’,jointcolumn’,’VariableNames’,{‘VariantID’,’Joint Column’});
jointcolumn = jointcolumn(ismember(jointcolumn.VariantID,VariantIDPassed),:);
jointtopordinarysegment = table((1:numel(jointtopordinarysegment))’,jointtopordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Top Ordinary Segment’});
jointtopordinarysegment = jointtopordinarysegment(ismember(jointtopordinarysegment.VariantID,VariantIDPassed),:);
jointbottomordinarysegment = table((1:numel(jointbottomordinarysegment))’,jointbottomordinarysegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Ordinary Segment’});
jointbottomordinarysegment = jointbottomordinarysegment(ismember(jointbottomordinarysegment.VariantID,VariantIDPassed),:);
jointtopspecialsegment = table((1:numel(jointtopspecialsegment))’,jointtopspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Top Special Segment’});
jointtopspecialsegment = jointtopspecialsegment(ismember(jointtopspecialsegment.VariantID,VariantIDPassed),:);
jointbottomspecialsegment = table((1:numel(jointbottomspecialsegment))’,jointbottomspecialsegment’,’VariableNames’,{‘VariantID’,’Joint Bottom Special Segment’});
jointbottomspecialsegment = jointbottomspecialsegment(ismember(jointbottomspecialsegment.VariantID,VariantIDPassed),:);
Zbottombeam{ijk} = table((1:numel(Zbottombeam{ijk,:}))’,Zbottombeam{ijk,:}’,’VariableNames’,{‘VariantID’,’Z Bottom Beam’});
Zbottombeam = Zbottombeam(VariantIDPassed);
%% Name the Frame
% column
for i = 1:height(VariantIDPassed)
jointIcolumn = 0;
jointJcolumn = 0;
jointcolumnnew{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointcolumnnew{i,:} = vertcat(jointbase.("Joint Base"){i},jointcolumnnew{i});
for j = 1:height(jointcolumnnew{i,1})-2
jointIcolumn(j) = jointcolumnnew{i,1}.ID(j);
jointJcolumn(j) = jointcolumnnew{i,1}.ID(j+2);
end
framecolumn{i,:} = table((1:j)’,jointIcolumn’,jointJcolumn’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Name the Frame
% top ordinary segment (TOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endTOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointtopordinarysegment.("Joint Top Ordinary Segment"){i}.Z),:);
jointTOS{i,:} = vertcat(jointtopordinarysegment.("Joint Top Ordinary Segment"){i},endTOS{i});
jointTOSnew1{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H),:),2);
jointTOSnew2{i,:} = sortrows(jointTOS{i}(ismember(jointTOS{i}.Z,H*Ns),:),2);
jointTOSnew{i,:} = vertcat(jointTOSnew1{i},jointTOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew1{i,1})-1
jointI(j) = jointTOSnew1{i,1}.ID(j);
jointJ(j) = jointTOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(framecolumn{i,1}.("Frame ID"));
frameTOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS1{i,1}(median(1:height(frameTOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTOSnew2{i,1})-1
jointI(j) = jointTOSnew2{i,1}.ID(j);
jointJ(j) = jointTOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS1{i,1}.("Frame ID"));
frameTOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameTOS2{i,1}(median(1:height(frameTOS2{i,1})),:) = [];
end
frameTOS = cellfun(@(varargin)vertcat(varargin{:}),frameTOS1,frameTOS2,’UniformOutput’,false);
%% Name the Frame
% bottom ordinary segment (BOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
endBOS{i,:} = jointcolumn.("Joint Column"){i}(ismember(jointcolumn.("Joint Column"){i}.Z,jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i}.Z),:);
jointBOS{i,:} = vertcat(jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i},endBOS{i});
jointBOSnew1{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(1)),:),2);
jointBOSnew2{i,:} = sortrows(jointBOS{i}(ismember(jointBOS{i}.Z,Zbottombeam{i}(2)),:),2);
jointBOSnew{i,:} = vertcat(jointBOSnew1{i},jointBOSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBOSnew1{i,1})-1
jointI(j) = jointBOSnew1{i,1}.ID(j);
jointJ(j) = jointBOSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTOS{i,1}.("Frame ID"));
frameBOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS1{i,1}(median(1:height(frameBOS1{i,1})),:) = [];
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ =0;
for j = 1:height(jointBOSnew2{i,1})-1
jointI(j) = jointBOSnew2{i,1}.ID(j);
jointJ(j) = jointBOSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS1{i,1}.("Frame ID"));
frameBOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
%eliminate special segment
frameBOS2{i,1}(median(1:height(frameBOS2{i,1})),:) = [];
end
frameBOS = cellfun(@(varargin)vertcat(varargin{:}),frameBOS1,frameBOS2,’UniformOutput’,false);
%% Name the Frame
% top special segment (TSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointTSSnew1{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H),:),2);
jointTSSnew2{i,:} = sortrows(jointtopspecialsegment.("Joint Top Special Segment"){i,1}(ismember(jointtopspecialsegment.("Joint Top Special Segment"){i,1}.Z,H*Ns),:),2);
jointTSSnew{i,:} = vertcat(jointTSSnew1{i},jointTSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew1{i,1})-1
jointI(j) = jointTSSnew1{i,1}.ID(j);
jointJ(j) = jointTSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBOS{i,1}.("Frame ID"));
frameTSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointTSSnew2{i,1})-1
jointI(j) = jointTSSnew2{i,1}.ID(j);
jointJ(j) = jointTSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS1{i,1}.("Frame ID"));
frameTSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameTSS = cellfun(@(varargin)vertcat(varargin{:}),frameTSS1,frameTSS2,’UniformOutput’,false);
%% Name the Frame
% bottom special segment (BSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
jointBSSnew1{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(1)),:),2);
jointBSSnew2{i,:} = sortrows(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}(ismember(jointbottomspecialsegment.("Joint Bottom Special Segment"){i,1}.Z,Zbottombeam{i}(2)),:),2);
jointBSSnew{i,:} = vertcat(jointBSSnew1{i},jointBSSnew2{i});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew1{i,1})-1
jointI(j) = jointBSSnew1{i,1}.ID(j);
jointJ(j) = jointBSSnew1{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameTSS{i,1}.("Frame ID"));
frameBSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(jointBSSnew2{i,1})-1
jointI(j) = jointBSSnew2{i,1}.ID(j);
jointJ(j) = jointBSSnew2{i,1}.ID(j+1);
end
lastframenumber{i,:} = max(frameBSS1{i,1}.("Frame ID"));
frameBSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameBSS = cellfun(@(varargin)vertcat(varargin{:}),frameBSS1,frameBSS2,’UniformOutput’,false);
%% Name the Frame
% diagonal ordinary segment (DOS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tosleft{i,:} = frameTOS{i,1}(1:2:end,:);
tosright{i,:} = frameTOS{i,1}(2:2:end,:);
bosleft{i,:} = frameBOS{i,1}(1:2:end,:);
bosright{i,:} = frameBOS{i,1}(2:2:end,:);
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tosleft{i,1})
jointI(j) = tosleft{i,1}.JointI(j);
jointJ(j) = bosleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameBSS{i,1}.("Frame ID"));
frameDOS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bosright{i,1})
jointI(j) = bosright{i,1}.JointI(j);
jointJ(j) = tosright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS1{i,1}.("Frame ID"));
frameDOS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDOS = cellfun(@(varargin)vertcat(varargin{:}),frameDOS1,frameDOS2,’UniformOutput’,false);
%% Name the Frame
% diagonal special segment (DSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
tssright{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
bssright{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDOS{i,1}.("Frame ID"));
frameDSS1{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(bssright{i,1})
jointI(j) = bssright{i,1}.JointI(j);
jointJ(j) = tssright{i,1}.JointJ(j);
end
lastframenumber{i,:} = max(frameDSS1{i,1}.("Frame ID"));
frameDSS2{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
frameDSS = cellfun(@(varargin)vertcat(varargin{:}),frameDSS1,frameDSS2,’UniformOutput’,false);
%% Name the Frame
% vertical special segment (VSS) (this phase is not automatic for different story)
for i = 1:height(VariantIDPassed)
tssleft{i,:} = frameTSS{i,1};
bssleft{i,:} = frameBSS{i,1};
end
for i = 1:height(VariantIDPassed)
jointI = 0;
jointJ = 0;
for j = 1:height(tssleft{i,1})
jointI(j) = tssleft{i,1}.JointI(j);
jointJ(j) = bssleft{i,1}.JointI(j);
end
lastframenumber{i,:} = max(frameDSS{i,1}.("Frame ID"));
frameVSS{i,:} = table((lastframenumber{i}+1:lastframenumber{i}+j)’,jointI’,jointJ’,’VariableNames’,{‘Frame ID’,’JointI’,’JointJ’});
end
%% Print ‘frame’ data to textline
txtframeCOLUMN = strings(height(framecolumn),1);
for i = 1:height(framecolumn)
T = framecolumn{i};
M = T{:,:};
txtframeCOLUMN(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTOS = strings(height(frameTOS),1);
for i = 1:height(frameTOS)
T = frameTOS{i};
M = T{:,:};
txtframeTOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBOS = strings(height(frameBOS),1);
for i = 1:height(frameBOS)
T = frameBOS{i};
M = T{:,:};
txtframeBOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeTSS = strings(height(frameTSS),1);
for i = 1:height(frameTSS)
T = frameTSS{i};
M = T{:,:};
txtframeTSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeBSS = strings(height(frameBSS),1);
for i = 1:height(frameBSS)
T = frameBSS{i};
M = T{:,:};
txtframeBSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDOS = strings(height(frameDOS),1);
for i = 1:height(frameDOS)
T = frameDOS{i};
M = T{:,:};
txtframeDOS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeDSS = strings(height(frameDSS),1);
for i = 1:height(frameDSS)
T = frameDSS{i};
M = T{:,:};
txtframeDSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
txtframeVSS = strings(height(frameVSS),1);
for i = 1:height(frameVSS)
T = frameVSS{i};
M = T{:,:};
txtframeVSS(i) = sprintf(" Frame=%d JointI=%d JointJ=%d IsCurved=No n",M.’);
end
%% Print ‘joint’ data to textline
txtjointBASE = strings(height(jointbase),1);
for i = 1:height(jointbase)
T = jointbase.("Joint Base"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBASE(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointCOLUMN = strings(height(jointcolumn),1);
for i = 1:height(jointcolumn)
T = jointcolumn.("Joint Column"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointCOLUMN(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTOS = strings(height(jointtopordinarysegment),1);
for i = 1:height(jointtopordinarysegment)
T = jointtopordinarysegment.("Joint Top Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBOS = strings(height(jointbottomordinarysegment),1);
for i = 1:height(jointbottomordinarysegment)
T = jointbottomordinarysegment.("Joint Bottom Ordinary Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBOS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointTSS = strings(height(jointtopspecialsegment),1);
for i = 1:height(jointtopspecialsegment)
T = jointtopspecialsegment.("Joint Top Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointTSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
txtjointBSS = strings(height(jointbottomspecialsegment),1);
for i = 1:height(jointbottomspecialsegment)
T = jointbottomspecialsegment.("Joint Bottom Special Segment"){i};
M = T{:,:};
M(:,end+[1 2]) = M(:,[2 3]); % duplicate columns 2 and 3 into columns 4 and 5
txtjointBSS(i) = sprintf(" Joint=%d CoordSys=GLOBAL CoordType=Cartesian XorR=%1.3f Y=0 Z=%1.3f SpecialJt=No GlobalX=%1.3f GlobalY=0 GlobalZ=%1.3fn",M.’);
end
%% WRITE s2k Extension Files
VariantModel = compose(‘%d’, 1:height(VariantIDPassed));
lined= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
for i = 1:numel(VariantModel)
writefile(VariantModel{i},txtjointBASE{i},txtjointCOLUMN{i},txtjointTOS{i},txtjointBOS{i},txtjointTSS{i},txtjointBSS{i},txtframeCOLUMN{i},txtframeTOS{i},txtframeBOS{i},txtframeTSS{i},txtframeBSS{i},txtframeDOS{i},txtframeDSS{i},txtframeVSS{i});
end
files = dir(‘*.s2k’);
files(:).name;
function writefile(C,txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS,txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS)
fido = fopen("ModelVariant"+C+".s2k",’wt’);
newline = ‘n’;
line1=’File D:MAGISTERKULIAHTESISS2K FILEModelVariant-%d.s2k was saved on m/d/yy at h:mm:ss’;
line2=’TABLE: "PROGRAM CONTROL"’;
line3=’ ProgramName=SAP2000 Version=25.0.0 ProgLevel=Ultimate LicenseNum=3010*1D6KZBK478DMQCT LicenseOS=Yes LicenseSC=Yes LicenseHT=No CurrUnits="KN, m, C" SteelCode="AISC 360-10" ConcCode="ACI 318-19" AlumCode="AA 2015" _’;
line4=’ ColdCode=AISI-16 RegenHinge=Yes’;
line5=’TABLE: "ACTIVE DEGREES OF FREEDOM"’;
line6=’ UX=Yes UY=No UZ=Yes RX=No RY=Yes RZ=No’;
line7=’TABLE: "ANALYSIS OPTIONS"’;
line8=’ Solver=Multithreaded SolverProc="Analysis Process" NumParallel=0 Force32Bit=No StiffCase=None GeomMod=None HingeOpt="In Elements" NumAThreads=0 MaxFileSize=0 NumDThreads=0 NumRThreads=0 _ UseMMFiles="Program Determined" AllowDiff=No’;
line9=’TABLE: "COORDINATE SYSTEMS"’;
line10=’ Name=GLOBAL Type=Cartesian X=0 Y=0 Z=0 AboutZ=0 AboutY=0 AboutX=0′;
line11=’TABLE: "GRID LINES"’;
line12=’ CoordSys=GLOBAL AxisDir=X GridID=A XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End AllVisible=Yes BubbleSize=1,5′;
line13=’ CoordSys=GLOBAL AxisDir=X GridID=B XRYZCoord=15 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line14=’ CoordSys=GLOBAL AxisDir=X GridID=C XRYZCoord=30 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line15=’ CoordSys=GLOBAL AxisDir=Y GridID=1 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=Start’;
line16=’ CoordSys=GLOBAL AxisDir=Z GridID=Z0 XRYZCoord=0 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line17=’ CoordSys=GLOBAL AxisDir=Z GridID=Z1 XRYZCoord=5 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line18=’ CoordSys=GLOBAL AxisDir=Z GridID=Z2 XRYZCoord=10 LineType=Primary LineColor=Gray8Dark Visible=Yes BubbleLoc=End’;
line19=’TABLE: "MATERIAL PROPERTIES 01 – GENERAL"’;
line20=’ Material=4000Psi Type=Concrete Grade="’ + "f’c 4000 " + ‘psi"’+ ‘ SymType=Isotropic TempDepend=No Color=Green GUID=b0920fc0-a39b-46e4-a096-037f0f0739a7 Notes="Customary ‘+"f’c 4000 psi "+’01/02/2024 20:13:33"’;
line21=’ Material=BJ-37 Type=Steel Grade="Grade 50" SymType=Isotropic TempDepend=No Color=Magenta Notes="ASTM A992 Grade 50 01/02/2024 20:03:34"’;
line22=’TABLE: "MATERIAL PROPERTIES 02 – BASIC MECHANICAL PROPERTIES"’;
line23=’ Material=4000Psi UnitWeight=23,5631216161854 UnitMass=2,40276960558926 E1=24855578,0600518 G12=10356490,8583549 U12=0,2 A1=9,89999952793124E-06′;
line24=’ Material=BJ-37 UnitWeight=76,9728639422648 UnitMass=7,84904737995992 E1=199947978,795958 G12=76903068,7676762 U12=0,3 A1=1,16999994421006E-05′;
line25=’TABLE: "MATERIAL PROPERTIES 03A – STEEL DATA"’;
line26=’ Material=BJ-37 Fy=235000 Fu=352500 EffFy=235000 EffFu=352500 SSCurveOpt=Simple SSHysType=Kinematic SHard=0,015 SMax=0,11 SRup=0,17 FinalSlope=-0,1 CoupModType="Von Mises"’;
line27=’TABLE: "MATERIAL PROPERTIES 06 – DAMPING PARAMETERS"’;
line28=’ Material=4000Psi ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line29=’ Material=BJ-37 ModalRatio=0 VisMass=0 VisStiff=0 HysMass=0 HysStiff=0′;
line30=’TABLE: "MATERIAL PROPERTIES 09 – ACCEPTANCE CRITERIA"’;
line31=’ Material=4000Psi IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,003 LSComp=-0,006 CPComp=-0,015 IgnoreTens=Yes’;
line32=’ Material=BJ-37 IOTens=0,01 LSTens=0,02 CPTens=0,05 IOComp=-0,005 LSComp=-0,01 CPComp=-0,02′;
line33=’TABLE: "FRAME SECTION PROPERTIES 01 – GENERAL"’;
line34=’ SectionName=ExampleWideFlanged Material=BJ-37 Shape="I/Wide Flange" t3=0,25 t2=0,15 tf=0,012 tw=0,008 t2b=0,15 tfb=0,012 FilletRadius=0,012 Area=0,005552 TorsConst=2,13418666666667E-07 I33=6,04638656154112E-05 _’;
line35=’ I22=6,76749435145855E-06 I23=-6,7762635780344E-21 AS2=0,00200790111881035 AS3=0,00357344416053972 S33Top=0,00048371092492329 S33Bot=0,00048371092492329 S22Left=9,02332580194473E-05 S22Right=9,02332580194473E-05 _’;
line36=’ Z33=0,000546402338734841 Z22=0,00013961366126516 R33=0,10435739412628 R22=0,0349131651083826 CGOffset3=-1,38777878078145E-17 CGOffset2=5,55111512312578E-17 EccV2=0 EccV3=0 Cw=9,558675E-08 ConcCol=No ConcBeam=No _’;
line37=’ Color=Blue TotalWt=60,3707599671425 TotalMass=6,15610399662034 FromFile=No AMod=1 A2Mod=1 A3Mod=1 JMod=1 I2Mod=1 I3Mod=1 MMod=1 WMod=1 Notes="Added 03/04/2024 20:08:55′;
line38=’TABLE: "LOAD PATTERN DEFINITIONS"’;
line39=’ LoadPat=DEAD DesignType=Dead SelfWtMult=1 GUID=d2c74fc0-a771-416d-b3dc-4b0a2047268d’;
line40=’ LoadPat=SUPERDEAD DesignType="Super Dead" SelfWtMult=0 GUID=91534b51-672f-4fb0-a037-d7225de00c69 Notes="Added 01/02/2024 20:08:11"’;
line41=’ LoadPat=LIVE DesignType=Live SelfWtMult=0 GUID=1f6f6fd1-e0f1-4fcb-bf3d-dc86bd53f1a8 Notes="Added 01/02/2024 20:08:16"’;
line42=’TABLE: "GROUPS 1 – DEFINITIONS"’;
line43=’ GroupName=All Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line44=’ GroupName=ST_Top Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line45=’ GroupName=ST_Bot Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line46=’ GroupName=ST_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line47=’ GroupName=ST_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line48=’ GroupName=OT_Top1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line49=’ GroupName=OT_Top2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Yellow’;
line49a=’ GroupName=OT_Bot1 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Gray8Dark’;
line49b=’ GroupName=OT_Bot2 Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Blue’;
line49c=’ GroupName=OT_Ver Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Green’;
line49d=’ GroupName=OT_Diag Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Cyan’;
line49e=’ GroupName=Column_End Selection=Yes SectionCut=Yes Steel=Yes Concrete=Yes Aluminum=Yes ColdFormed=Yes Stage=Yes Bridge=Yes AutoSeismic=No AutoWind=No SelDesSteel=No SelDesAlum=No SelDesCold=No MassWeight=Yes Color=Red’;
line50=’TABLE: "JOINT PATTERN DEFINITIONS"’;
line51=’ Pattern=Default’;
line52=’TABLE: "MASS SOURCE"’;
line53=’ MassSource=MSSSRC1 Elements=Yes Masses=Yes Loads=Yes IsDefault=Yes LoadPat=DEAD Multiplier=1′;
line54=’ MassSource=MSSSRC1 LoadPat=SUPERDEAD Multiplier=1′;
line55=’ MassSource=MSSSRC1 LoadPat=LIVE Multiplier=0,5′;
line56=’TABLE: "LOAD CASE DEFINITIONS"’;
line57=’ Case=DEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=91b91585-f6e6-446e-ac30-362013fd8af9′;
line58=’ Case=MODAL Type=LinModal InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Other DesActOpt="Prog Det" DesignAct=Other AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=3e160405-efbf-45fb-ae06-c6da634ca183′;
line59=’ Case=SUPERDEAD Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType="Super Dead" DesActOpt="Prog Det" DesignAct="Long-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=2ca565b7-af73-42e9-9208-0a0739594699′;
line60=’ Case=LIVE Type=LinStatic InitialCond=Zero DesTypeOpt="Prog Det" DesignType=Live DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e969dd8f-56cc-40d7-af8a-0fba39157fcb’;
line61=’ Case="Gravity NLS" Type=NonStatic InitialCond=Zero MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Dead DesActOpt="Prog Det" DesignAct=Non-Composite AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line62=’ Case=Pushover-UX Type=NonStatic InitialCond="Gravity NLS" MassSource=MSSSRC1 DesTypeOpt="Prog Det" DesignType=Quake DesActOpt="Prog Det" DesignAct="Short-Term Composite" AutoType=None RunCase=Yes CaseStatus="Not Run" GUID=e13dc273-9465-4be3-a170-d60ddec6e3ae’;
line63=’TABLE: "CASE – STATIC 1 – LOAD ASSIGNMENTS"’;
line64=’ Case=DEAD LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line65=’ Case=SUPERDEAD LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line66=’ Case=LIVE LoadType="Load pattern" LoadName=LIVE LoadSF=1′;
line67=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=DEAD LoadSF=1′;
line68=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=SUPERDEAD LoadSF=1′;
line69=’ Case="Gravity NLS" LoadType="Load pattern" LoadName=LIVE LoadSF=0,5′;
line70=’ Case=Pushover-UX LoadType=Accel LoadName="Accel UX" TransAccSF=-1′;
line71=’TABLE: "CASE – STATIC 2 – NONLINEAR LOAD APPLICATION"’;
line72=’ Case="Gravity NLS" LoadApp="Full Load" MonitorDOF=U1 MonitorJt=9′;
line73=’ Case=Pushover-UX LoadApp="Displ Ctrl" DisplType=Monitored TargetDispl=1 MonitorDOF=U1 MonitorJt=9′;
line74=’TABLE: "CASE – STATIC 4 – NONLINEAR PARAMETERS"’;
line75=’ Case="Gravity NLS" GeoNonLin=P-Delta ResultsSave="Final State" SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 _’;
line76=’ TFAccelFact=1 TFNoStop=No’;
line77=’ Case=Pushover-UX GeoNonLin=P-Delta ResultsSave="Multiple States" MinNumState=10 MaxNumState=100 PosIncOnly=Yes SolScheme="Iterative Events" MaxTotal=200 MaxNull=50 EvLumpTol=0,01 MaxEvPerStp=24 MaxIterCS=10 _’;
line78=’ MaxIterNR=40 ItConvTol=0,0001 TFMaxIter=10 TFTol=0,01 TFAccelFact=1 TFNoStop=No’;
line79=’TABLE: "CASE – MODAL 1 – GENERAL"’;
line80=’ Case=MODAL ModeType=Eigen MaxNumModes=12 MinNumModes=1 EigenShift=0 EigenCutoff=0 EigenTol=1E-09 AutoShift=Yes’;
line81=’TABLE: "JOINT COORDINATES"’;
line82= append(txtjointBASE,txtjointCOLUMN,txtjointTOS,txtjointBOS,txtjointTSS,txtjointBSS);
line83=’TABLE: "CONNECTIVITY – FRAME"’;
line84= append(txtframeCOLUMN,txtframeTOS,txtframeBOS,txtframeTSS,txtframeBSS,txtframeDOS,txtframeDSS,txtframeVSS);
line85=’TABLE: "END TABLE DATA"’;
combine1 = append(line1,newline,line2,newline,line3,newline,line4,newline,line5,newline,line6,newline,line7,newline,line8,newline,line9,newline,line10,newline,line11,newline,line12,newline,line13,newline,line14,newline,line15,newline,line16,newline,line17,newline,line18,newline,line19,newline,line20,newline,line21,newline,line22,newline,line23,newline,line24,newline,line25,newline,line26,newline,line27,newline,line28,newline,line29,newline,line30,newline,line31,newline,line32,newline,line33,newline,line34,newline,line35,newline,line36);
combine2 = append(combine1,newline,line37,newline,line38,newline,line39,newline,line40,newline,line41,newline,line42,newline,line43,newline,line44,newline,line45,newline,line46,newline,line47,newline,line48,newline,line49,newline,line49a,newline,line49b,newline,line49c,newline,line49d,newline,line49e,newline,line50,newline,line51,newline,line52,newline,line53,newline,line54,newline,line55,newline,line56,newline,line57,newline,line58,newline,line59,newline,line60,newline,line61,newline,line62,newline,line63,newline,line64,newline,line65,newline,line66,newline,line67,newline,line68,newline);
combine3 = append(combine2,line69,newline,line70,newline,line71,newline,line72,newline,line73,newline,line74,newline,line75,newline,line76,newline,line77,newline,line78,newline,line79,newline,line80,newline,line81,newline,line82,newline,line83,newline,line84,newline,line85);
fprintf(fido,combine3,C);
fclose(fido);
end sprintf, function MATLAB Answers — New Questions
Write the lines (sentences) of a 1513 x 1 string into separate lines in a text file, keeping the whole length of each sentence, without breaking them.
This is the function I am using: writelines(newstr,"c:userslnitzdownloadstarnowagain.txt")
newstr is a 1513 x 1 string, consisting of whole sentences from a story.Many sentences are quite long.
The text below was two sentences (each in a single line) in the string document. but appears broken into four lines in the writelines output.
Sie hatte keine Kinder, und mir wurde daher
der ganze Reichthum ihres Herzens an Liebe.
Seit meinem zehnten Jahre war sie mir Pflegerin
und Erzieherin, und mein Herz liebte und ehrte sie wie eine zweite Mutter.
My ideal is to have either a text file with one sentence per line or a spreadsheet with one sentence in the first cell of each line. This woujld be input to a text program that focuses on sentences.This is the function I am using: writelines(newstr,"c:userslnitzdownloadstarnowagain.txt")
newstr is a 1513 x 1 string, consisting of whole sentences from a story.Many sentences are quite long.
The text below was two sentences (each in a single line) in the string document. but appears broken into four lines in the writelines output.
Sie hatte keine Kinder, und mir wurde daher
der ganze Reichthum ihres Herzens an Liebe.
Seit meinem zehnten Jahre war sie mir Pflegerin
und Erzieherin, und mein Herz liebte und ehrte sie wie eine zweite Mutter.
My ideal is to have either a text file with one sentence per line or a spreadsheet with one sentence in the first cell of each line. This woujld be input to a text program that focuses on sentences. This is the function I am using: writelines(newstr,"c:userslnitzdownloadstarnowagain.txt")
newstr is a 1513 x 1 string, consisting of whole sentences from a story.Many sentences are quite long.
The text below was two sentences (each in a single line) in the string document. but appears broken into four lines in the writelines output.
Sie hatte keine Kinder, und mir wurde daher
der ganze Reichthum ihres Herzens an Liebe.
Seit meinem zehnten Jahre war sie mir Pflegerin
und Erzieherin, und mein Herz liebte und ehrte sie wie eine zweite Mutter.
My ideal is to have either a text file with one sentence per line or a spreadsheet with one sentence in the first cell of each line. This woujld be input to a text program that focuses on sentences. text ouput, write string to line. MATLAB Answers — New Questions
How to optimize the run time in my optimization problem.
Hi guys. I have an optimization problem. The code is as follows:
Objective=@MassTransferErrors;
kL=0.5;
kH=0.5;
p0=[kL,kH];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[0 ; 0];
ub=[100;100];
k = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(k)
function MTE=MassTransferErrors(p)
kL = p(1);
kH = p(2);
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i)); %Converting Experiments set to matrix
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^5; %Defining an Mass Transfer Error relation
MTE_j(i) = MTE_i; %Defines a Mass Transfer Error Vector(1*7) that contains the error for each case
end
MTE = sum(MTE_j(1:7)); %Objective function(Sum of the all arrays in MTE_j Vector) what I need to minimize is each array that is on the MTE_j Vector but since I can’t return a Vector as an objective function I sum all the arrays as my objective function.
end
What I need to minimize in this problem are all the seven values in MTE_j vector but since objective function can’t return a vector. I have used the sum of the all values. I doubt this is the correct way to minimize all the seven values in MTE_j vector also my code took an extremely long run time(6 hours last time I have checked with no answers yet) . I know the objective function is complicated but I guess I’m doing something wrong. I also test my objective function with an assumption for kL and kH values. my objective function code seems to work OK. Here’s the test code:
%%Test Objective function
kL = 0.1; %Assumption for kL
kH = 0.1; %Assumption for kH
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i));
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^2;
MTE_j(i) = MTE_i;
end
MTE = sum(MTE_j(1:7));
I just want the kL and kH values that minimize each value on MTE_j vector and I want a code to actually give me these values. My code take an extremely long run time with no answers.Hi guys. I have an optimization problem. The code is as follows:
Objective=@MassTransferErrors;
kL=0.5;
kH=0.5;
p0=[kL,kH];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[0 ; 0];
ub=[100;100];
k = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(k)
function MTE=MassTransferErrors(p)
kL = p(1);
kH = p(2);
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i)); %Converting Experiments set to matrix
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^5; %Defining an Mass Transfer Error relation
MTE_j(i) = MTE_i; %Defines a Mass Transfer Error Vector(1*7) that contains the error for each case
end
MTE = sum(MTE_j(1:7)); %Objective function(Sum of the all arrays in MTE_j Vector) what I need to minimize is each array that is on the MTE_j Vector but since I can’t return a Vector as an objective function I sum all the arrays as my objective function.
end
What I need to minimize in this problem are all the seven values in MTE_j vector but since objective function can’t return a vector. I have used the sum of the all values. I doubt this is the correct way to minimize all the seven values in MTE_j vector also my code took an extremely long run time(6 hours last time I have checked with no answers yet) . I know the objective function is complicated but I guess I’m doing something wrong. I also test my objective function with an assumption for kL and kH values. my objective function code seems to work OK. Here’s the test code:
%%Test Objective function
kL = 0.1; %Assumption for kL
kH = 0.1; %Assumption for kH
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i));
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^2;
MTE_j(i) = MTE_i;
end
MTE = sum(MTE_j(1:7));
I just want the kL and kH values that minimize each value on MTE_j vector and I want a code to actually give me these values. My code take an extremely long run time with no answers. Hi guys. I have an optimization problem. The code is as follows:
Objective=@MassTransferErrors;
kL=0.5;
kH=0.5;
p0=[kL,kH];
A = [];
b = [];
Aeq = [];
beq = [];
lb=[0 ; 0];
ub=[100;100];
k = fmincon(Objective, p0, A, b, Aeq, beq, lb, ub);
disp(k)
function MTE=MassTransferErrors(p)
kL = p(1);
kH = p(2);
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i)); %Converting Experiments set to matrix
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^5; %Defining an Mass Transfer Error relation
MTE_j(i) = MTE_i; %Defines a Mass Transfer Error Vector(1*7) that contains the error for each case
end
MTE = sum(MTE_j(1:7)); %Objective function(Sum of the all arrays in MTE_j Vector) what I need to minimize is each array that is on the MTE_j Vector but since I can’t return a Vector as an objective function I sum all the arrays as my objective function.
end
What I need to minimize in this problem are all the seven values in MTE_j vector but since objective function can’t return a vector. I have used the sum of the all values. I doubt this is the correct way to minimize all the seven values in MTE_j vector also my code took an extremely long run time(6 hours last time I have checked with no answers yet) . I know the objective function is complicated but I guess I’m doing something wrong. I also test my objective function with an assumption for kL and kH values. my objective function code seems to work OK. Here’s the test code:
%%Test Objective function
kL = 0.1; %Assumption for kL
kH = 0.1; %Assumption for kH
%% Constants
tMax=18000; % reaction duration (s)
Q0=[100 200 350 400 400 400 500]; % Q_G etylene inflow (ml/min)
T_C =[230 230 230 180 200 230 230]; %T for different cases
MTE_j=zeros(1,7);
Experiments = {[ 0.2985 0.6498 0.6147 0.43917 0.40398],[0.68662 1.6373 1.4260 1.4437 1.53169],[2.90493 5.68662 5.75704 2.65845 1.00352],[3.50352 11.3908 6.77817 3.46831 2.2007],[4.73592 10.8979 4.48944 3.01056 2.76408],[4.80634 9.45423 6.60211 4.03169 2.83451],[4.41901 10.4754 7.09507 4.13732 2.27113]};
for i=1:7
Q1=Q0(i)*1e-6/60; % Q_G ethylene inflow (m3/s)
Q2=0; % Q_G butene inflow
Q3=0; % Q_G hexene inflow
Q4=0; % Q_G octene inflow
Q5=0; % Q_G decene inflow
Q6=0; % Q_G dodecene inflow
Q7=0; % Q_G undecane inflow
P1=36e5; % ethylene inflow pressure [Pa]
T1=T_C(i)+273.15; % T_Ethylene [K]
T2=230+273.15; % T_ref [K]
R=8.314; % gas constant [J/(mol.K)]
C1=P1/(R*T1); % ethylene inlet gas concentration [mol/m^3]
VR=300e-6; % reactor volume [m^3]
VG=250e-6; % gas volume [m^3]
VL=50e-6; % liquid volume [m^3]
K=[3.24;2.23;1.72;0.2;0.1;0.08;0.09]; % solubility [nondim]
moleWt=[28;56;84;112;140;168;156]; % mole weight C2,C4,…,C12,C11 [g/mol]
wc=(0.3+0.25)*1e-3; % catalyst weight [kg]
kref=[2.224e-4;1.533e-4;3.988e-5;1.914e-7;4.328e-5;…
2.506e-7;4.036e-5;1.062e-6;6.055e-7;]; % rate at Tref=230C [mol/(s.g_cat)]
Eact=[109.5; 15.23; 7.88; 44.45; 9.438; 8.426; 10.91; 12.54; 7.127]; % activation energy [J/mol];
k=kref.*exp(-Eact*(1/T1-1/T2)/R); % rate at T=T2 [mol/(s.g)]
tauOF=5; % outflow time constant (s)
% Specify initial conditions
xinit=zeros(15,1); % initial state vector
xinit(1)=C1*VR; % initial ethylene in gas (mol)
xinit(14)=36.63/156; % initial undecane in liquid (mol)
xinit(7) = xinit(14)*VG*K(7)/VL; % initial undecane in gas (mol)
xinit(8) = xinit(1)*VL/(K(1)*VG); % initial ethylene in liquid (mol)
xinit(15)=Q1*C1; % initial outflow rate (mol/s)
nToti=sum(xinit(1:7)); % initial moles in gas (mol)
dNdt=@(t,x) [Q1*C1-x(15)*x(1)/sum(x(1:7))-VR*kL*(x(1)/VG-K(1)*x(8)/VL); % gas phase ethylene (mol/s)
Q2-x(15)*x(2)/sum(x(1:7))-VR*kL*(x(2)/VG-K(2)*x(9)/VL); % gas phase butene (mol/s)
Q3-x(15)*x(3)/sum(x(1:7))-VR*kL*(x(3)/VG-K(3)*x(10)/VL); % gas phase hexene (mol/s)
Q4-x(15)*x(4)/sum(x(1:7))-VR*kH*(x(4)/VG-K(4)*x(11)/VL); % gas phase octene (mol/s)
Q5-x(15)*x(5)/sum(x(1:7))-VR*kH*(x(5)/VG-K(5)*x(12)/VL); % gas phase decene (mol/s)
Q6-x(15)*x(6)/sum(x(1:7))-VR*kH*(x(6)/VG-K(6)*x(13)/VL); % gas phase dodecene (mol/s)
Q7-x(15)*x(7)/sum(x(1:7))-VR*kH*(x(7)/VG-K(7)*x(14)/VL); % gas phase undecane (mol/s)
VR*kL*(x(1)/VG-K(1)*x(8)/VL)+wc*(-2*k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(5)*x(8)*x(11)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kL*(x(2)/VG-K(2)*x(9)/VL)+wc*(k(1)*x(8)^2/VL^2-k(2)*x(8)*x(9)/VL^2-2*k(4)*x(9)^2/VL.^2-k(6)*x(9)*x(10)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kL*(x(3)/VG-K(3)*x(10)/VL)+wc*(k(2)*x(8)*x(9)/VL^2-k(3)*x(8)*x(10)/VL^2-k(6)*x(9)*x(10)/VL.^2-2*k(9)*x(10)^2/VL^2);
VR*kH*(x(4)/VG-K(4)*x(11)/VL)+wc*(k(3)*x(8)*x(10)/VL^2+k(4)*x(9)^2/VL^2-k(5)*x(8)*x(11)/VL^2-k(8)*x(9)*x(11)/VL^2);
VR*kH*(x(5)/VG-K(5)*x(12)/VL)+wc*(k(5)*x(8)*x(11)/VL^2+k(6)*x(9)*x(10)/VL^2-k(7)*x(8)*x(12)/VL^2);
VR*kH*(x(6)/VG-K(6)*x(13)/VL)+wc*(k(7)*x(8)*x(12)/VL^2+k(8)*x(9)*x(11)/VL^2+k(9)*x(10)^2/VL^2);
VR*kH*(x(7)/VG-K(7)*x(14)/VL);
(sum(x(1:7))-nToti)/tauOF]; % d(outflow rate)/dt (mol/s^2)
[t,x]=ode45(dNdt,[0,tMax],xinit);
molGend=x(end,1:7);
molLend=x(end,8:14);
massGend=molGend’.*moleWt;
massLend=molLend’.*moleWt;
%Total Product
TotalProduct = zeros(1,7);
for j=1:7
TotalProduct(j) = massGend(j) + massLend(j); %Sum of the liquid and gas phase products(g)
end
Experiment_i = cell2mat(Experiments(i));
MTE_i = (TotalProduct(2)-Experiment_i(1))^2+(TotalProduct(3)-Experiment_i(2))^2+(TotalProduct(4)-Experiment_i(3))^2+(TotalProduct(5)-Experiment_i(4))^2+(TotalProduct(6)-Experiment_i(5))^2;
MTE_j(i) = MTE_i;
end
MTE = sum(MTE_j(1:7));
I just want the kL and kH values that minimize each value on MTE_j vector and I want a code to actually give me these values. My code take an extremely long run time with no answers. optimization MATLAB Answers — New Questions
Pulley with two hanging masses
Hello all,
I have been trying to simulate the classic physics problem: a pulley with two hanging masses. I am not sure which part did I messed up, but even though I set the weight for the two masses significantly different, the slipping does not occur, and the body just swings left and right, but not one up one down as expected.
I have uploaded my simulink document below. I should also state that I am using gravity in the -Y direction.
Any help would be greatly appreciated!Hello all,
I have been trying to simulate the classic physics problem: a pulley with two hanging masses. I am not sure which part did I messed up, but even though I set the weight for the two masses significantly different, the slipping does not occur, and the body just swings left and right, but not one up one down as expected.
I have uploaded my simulink document below. I should also state that I am using gravity in the -Y direction.
Any help would be greatly appreciated! Hello all,
I have been trying to simulate the classic physics problem: a pulley with two hanging masses. I am not sure which part did I messed up, but even though I set the weight for the two masses significantly different, the slipping does not occur, and the body just swings left and right, but not one up one down as expected.
I have uploaded my simulink document below. I should also state that I am using gravity in the -Y direction.
Any help would be greatly appreciated! simulink, simscape MATLAB Answers — New Questions
How to Set Specific Arg in Function
Hi, I’m trying to use th function give at this link:
https://uk.mathworks.com/matlabcentral/fileexchange/47165-heatscatter-plot-for-variables-x-and-y
When I set the default values it works fine ie:
heatscatter(workingr, workingi,”, ‘test.png’);
However I would now like to add a title, but I cannot figure out how to do this. I’ve tried seraching for how to change/edit/give a specific argument but I can’t find it. I’ve tried the following options but none seem to work:
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, ‘testtitle’);
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, testtitle);
heatscatter(workingr, workingi,”, ‘test.png’, title, testtitle);
I always get the error:
Nonfinite endpoints or increment for colon operator in index.
When I fill out the entire list of args as:
heatscatter(workingr, workingi,”, ‘test.png’,’300′, ’10’, ‘.’, 0, 0, ‘test’, ‘test2′,’title’);
I can control all the parameters, except title – I get the following error:
Index exceeds the number of array elements (5).
Error in heatscatter (line 186)
title(title);
What am I doing wrong? Thanks in advance.Hi, I’m trying to use th function give at this link:
https://uk.mathworks.com/matlabcentral/fileexchange/47165-heatscatter-plot-for-variables-x-and-y
When I set the default values it works fine ie:
heatscatter(workingr, workingi,”, ‘test.png’);
However I would now like to add a title, but I cannot figure out how to do this. I’ve tried seraching for how to change/edit/give a specific argument but I can’t find it. I’ve tried the following options but none seem to work:
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, ‘testtitle’);
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, testtitle);
heatscatter(workingr, workingi,”, ‘test.png’, title, testtitle);
I always get the error:
Nonfinite endpoints or increment for colon operator in index.
When I fill out the entire list of args as:
heatscatter(workingr, workingi,”, ‘test.png’,’300′, ’10’, ‘.’, 0, 0, ‘test’, ‘test2′,’title’);
I can control all the parameters, except title – I get the following error:
Index exceeds the number of array elements (5).
Error in heatscatter (line 186)
title(title);
What am I doing wrong? Thanks in advance. Hi, I’m trying to use th function give at this link:
https://uk.mathworks.com/matlabcentral/fileexchange/47165-heatscatter-plot-for-variables-x-and-y
When I set the default values it works fine ie:
heatscatter(workingr, workingi,”, ‘test.png’);
However I would now like to add a title, but I cannot figure out how to do this. I’ve tried seraching for how to change/edit/give a specific argument but I can’t find it. I’ve tried the following options but none seem to work:
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, ‘testtitle’);
heatscatter(workingr, workingi,”, ‘test.png’, ‘title’, testtitle);
heatscatter(workingr, workingi,”, ‘test.png’, title, testtitle);
I always get the error:
Nonfinite endpoints or increment for colon operator in index.
When I fill out the entire list of args as:
heatscatter(workingr, workingi,”, ‘test.png’,’300′, ’10’, ‘.’, 0, 0, ‘test’, ‘test2′,’title’);
I can control all the parameters, except title – I get the following error:
Index exceeds the number of array elements (5).
Error in heatscatter (line 186)
title(title);
What am I doing wrong? Thanks in advance. set, args, function MATLAB Answers — New Questions
smart function to switch functions
Suppose I want to tune different ode solvers to run:
ode23(@fun,…)
I want to use ‘odesolver’ so that
odesolver(@fun,…) actually runs ode23(@fun,…) when specifying odesolver==’ode23′. Is there a smart way to do it?Suppose I want to tune different ode solvers to run:
ode23(@fun,…)
I want to use ‘odesolver’ so that
odesolver(@fun,…) actually runs ode23(@fun,…) when specifying odesolver==’ode23′. Is there a smart way to do it? Suppose I want to tune different ode solvers to run:
ode23(@fun,…)
I want to use ‘odesolver’ so that
odesolver(@fun,…) actually runs ode23(@fun,…) when specifying odesolver==’ode23′. Is there a smart way to do it? matlab function MATLAB Answers — New Questions
I am trying to solve the system of two linear differential equations and create a phase diagram to asses the stability of the system.
dot{dot{y} =-deltagammabeta(y-y_n)-deltagammalambda(p-p_t)}
dot{dot{p}=alpha(y-y_n)}dot{dot{y} =-deltagammabeta(y-y_n)-deltagammalambda(p-p_t)}
dot{dot{p}=alpha(y-y_n)} dot{dot{y} =-deltagammabeta(y-y_n)-deltagammalambda(p-p_t)}
dot{dot{p}=alpha(y-y_n)} differential equations, phase diagram, plotting MATLAB Answers — New Questions
The standard implementation of ldl factorization in Matlab does not work correctly
The ldl(P) applied to symmetric matrix P should return a lover-triangular matrix L and a diagonal matrix D, such that:
.
The attached file contain the 9×9 symmetric matrix P, which ldl doesn’t works with correctly:
load(‘ldl_fail.mat’);
P % original symmetric matrix
max(max(P-P’))
[L,D] = ldl(P);
L % incorrect lover-triangular matrix factor
diag(D)’
L_ = chol(P)’; D_ = diag(L_).^2; L_ = tril(L,-1)+eye(size(L));
L_ % correct lover-triangular matrix factor (obtained with chol() function)
D_’The ldl(P) applied to symmetric matrix P should return a lover-triangular matrix L and a diagonal matrix D, such that:
.
The attached file contain the 9×9 symmetric matrix P, which ldl doesn’t works with correctly:
load(‘ldl_fail.mat’);
P % original symmetric matrix
max(max(P-P’))
[L,D] = ldl(P);
L % incorrect lover-triangular matrix factor
diag(D)’
L_ = chol(P)’; D_ = diag(L_).^2; L_ = tril(L,-1)+eye(size(L));
L_ % correct lover-triangular matrix factor (obtained with chol() function)
D_’ The ldl(P) applied to symmetric matrix P should return a lover-triangular matrix L and a diagonal matrix D, such that:
.
The attached file contain the 9×9 symmetric matrix P, which ldl doesn’t works with correctly:
load(‘ldl_fail.mat’);
P % original symmetric matrix
max(max(P-P’))
[L,D] = ldl(P);
L % incorrect lover-triangular matrix factor
diag(D)’
L_ = chol(P)’; D_ = diag(L_).^2; L_ = tril(L,-1)+eye(size(L));
L_ % correct lover-triangular matrix factor (obtained with chol() function)
D_’ matrix decomposition error, standard implementation error MATLAB Answers — New Questions