Below is the Matlab file in which to perform the procedures listed, show how to
ID: 3750607 • Letter: B
Question
Below is the Matlab file in which to perform the procedures listed, show how to input it into Matlab.
% ET 202 HW 02
% Name
% Date
% Strength of Materials / Steel Table
clear
format compact; format short g
% Table T15_9 is defined below wiith some mistakkes.
% Run the file then use proper indexing commands to correct the mistakes
% Do NOT just re-type the incorrect values.
T15_9=[
22.4 23.92 0.440 9.880 0.680 2100 176
20.1 23.73 0.415 8.965 0.585 1830 154
21.5 24.21 0.554 8.295 0.740 6100 151
16.7 21.06 0.405 5.666 0.650 1170 111
16.2 18.11 0.390 7.530 0.630 890 98.3]
% Part a
% Use a proper commands to modify the incorrect elements in the table (Do
% not just re-define the varible T15_9)
T15_9_0( , ) =
% Results for part a (copy from command window)
% Part b
% Use single command to find ONLY the number of rows of the given variable
% and save it to the variable T_row
% c. Use single command to find ONLY the number of clumns of the given
% variable and save it to the variable T_col
% d. Use a proper indexing command to extract the columns that includes only
% the dimensions of the sections (the first five columns) and save them to
% a to the variable T15_9_dim
% e. Use a proper indexing command to extract the columns that includes only
% the properties of the sections (the last two columns) and save them to
% a to the variable T15_9_prop
% f. Use a proper indexing command to extract the depth column and save it
% to the variable d
% g. Use a proper indexing command to extract the web thickness column and
% save it to the variable t_w
% h. Create a new variable for the web area, A_w, which results from
% multiplying each depth value by its corressponding web thickness value
% (A_w_i = d_i * t_w_i)
% i. Use the fprintf to print the values of the 3rd section web area and
% moment of inertia that appear as:
% 'The web area of the 3rd section (W21x73) is ####.## in^2 and the moment
% of inertia is ####.## in^4'
% j
% k
% l. Expand the variable T15_9 by adding an extra row (data for W18x40) using
% a proper indexing command. Do not just add the values in the original
% variable definition above
Explanation / Answer
% ET 202 HW 02
% Name
% Date
% Strength of Materials / Steel Table
clear
format compact; format short g
% Table T15_9 is defined below wiith some mistakkes.
% Run the file then use proper indexing commands to correct the mistakes
% Do NOT just re-type the incorrect values.
T15_9=[
22.4 23.92 0.440 9.880 0.680 2100 176
20.1 23.73 0.415 8.965 0.585 1830 154
21.5 24.21 0.554 8.295 0.740 6100 151
16.7 21.06 0.405 5.666 0.650 1170 111
16.2 18.11 0.390 7.530 0.630 890 98.3];
% Part a
% Use a proper commands to modify the incorrect elements in the table (Do
% not just re-define the varible T15_9)
T15_9(1, 4)=8.990;
T15_9(3, 2)=21.24;
T15_9(3, 3)=0.455;
T15_9(3, 6)=1600;
T15_9(4, 4)=6.555;
% Results for part a (copy from command window)
% Part b
% Use single command to find ONLY the number of rows of the given variable
% and save it to the variable T_row
t=size(T15_9);
T_rows=t(1);
% c. Use single command to find ONLY the number of clumns of the given
% variable and save it to the variable T_col
T_cols=t(2);
% d. Use a proper indexing command to extract the columns that includes only
% the dimensions of the sections (the first five columns) and save them to
% a to the variable T15_9_dim
T15_9_dim=T15_9(:, 1:5);
% e. Use a proper indexing command to extract the columns that includes only
% the properties of the sections (the last two columns) and save them to
% a to the variable T15_9_prop
T15_9_prop=T15_9(:, 6:7);
% f. Use a proper indexing command to extract the depth column and save it
% to the variable d
d=T15_9(:, 2);
% g. Use a proper indexing command to extract the web thickness column and
% save it to the variable t_w
t_w=T15_9(:, 3);
% h. Create a new variable for the web area, A_w, which results from
% multiplying each depth value by its corressponding web thickness value
% (A_w_i = d_i * t_w_i)
A_w=[];
for i=1:length(d)
A_w(1)=d(i)*t_w(i);
end
% i. Use the fprintf to print the values of the 3rd section web area and
% moment of inertia that appear as:
% 'The web area of the 3rd section (W21x73) is ####.## in^2 and the moment
% of inertia is ####.## in^4'
fprintf('the web area of the 3rd section (W21x73) is %.3 in^2 and the moment of inertia is %.3f ', T15_9(3, 1), T15_9(3, 6))
% j and k
area=T15_9(:, 1);
w1=[24 24 21 21 18];
w2=[76 68 73 57 55];
for i=1:length(area)
fprintf('The web area of section W%.0fx%.0f is %.3f ', w1(i), w2(i), area(i))
end
% l. Expand the variable T15_9 by adding an extra row (data for W18x40) using
% a proper indexing command. Do not just add the values in the original
% variable definition above
T_newRow=[11.8 17.90 0.315 6.015 0.525 612 68.4];
T15_9(6, :)=T_newRow;
As asked in the question, I have completed the code. Proper indexing commands have been used in the code (as per Matlab convention).
Note : If A is an array/vector in Matlab, just use A(row, col) to access its elements, also for other modifications such as replacing its elements, adding new rows.
I have not used code indentation. If requested for code indentation, I have screenshot of this code, I will it although there are more 3 screenshots.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.