How can I put an output from the display function in a table?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there,
I am wondering how I can put the results using the display function into a table.
This is the code:
Section = ['254 x 254 x 73';'254 x 146 x 31';'254 x 146 x 31';'254 x 254 x 73';'254 x 254 x 73';'152 x 152 x 51';'152 x 152 x 51';'152 x 152 x 51';'203 x 203 x 46';'203 x 203 x 52'];
h = [254.1; 251.4; 251.4; 254.1; 254.1; 170.2; 170.2; 170.2; 203.2; 206.2];
b = [254.6; 146.1; 146.1; 254.6; 254.6; 157.4; 157.4; 157.4; 203.6; 204.3];
tw = [8.6; 6.00; 6.00; 8.6; 8.6; 11.00; 11.00; 11.00; 7.2; 7.9];
tf = [14.2; 8.6; 8.6; 14.2; 14.2; 15.7; 15.7; 15.7; 11.00; 12.5];
r = [12.7; 7.6; 7.6; 12.7; 12.7; 7.6; 7.6; 7.6; 10.2; 10.2];
E = 0.81;
for i = 1:length(h)
Cw(i) = h(i) - 2*(tf(i)) - 2*(r(i));
c_w(i) = Cw(i)/(tw(i));
if c_w(i) < 72*E
disp("Web is class 1")
else
disp("Web is not class 1")
end
Cf(i) = b(i)/2 - tw(i)/2 - r(i);
c_f(i) = Cf(i)/tf(i);
if c_f(i) < 9*E
disp("Flange is class 1")
elseif c_f(i) < 10*E
disp("Flange is class 2")
else
disp("Section is Class 3 or 4")
end
end
I would like to have a table with the 'sections' displaying "Web is class 1" or "Flange is class 2". MATLAB doesn't seem to let me assign a variable to the display function, so I can't work out how to put the data into a table.
Can someone help please?
0 commentaires
Réponses (2)
VBBV
le 25 Mar 2024
Modifié(e) : VBBV
le 25 Mar 2024
Section = ['254 x 254 x 73';'254 x 146 x 31';'254 x 146 x 31';'254 x 254 x 73';'254 x 254 x 73';'152 x 152 x 51';'152 x 152 x 51';'152 x 152 x 51';'203 x 203 x 46';'203 x 203 x 52'];
h = [254.1; 251.4; 251.4; 254.1; 254.1; 170.2; 170.2; 170.2; 203.2; 206.2];
b = [254.6; 146.1; 146.1; 254.6; 254.6; 157.4; 157.4; 157.4; 203.6; 204.3];
tw = [8.6; 6.00; 6.00; 8.6; 8.6; 11.00; 11.00; 11.00; 7.2; 7.9];
tf = [14.2; 8.6; 8.6; 14.2; 14.2; 15.7; 15.7; 15.7; 11.00; 12.5];
r = [12.7; 7.6; 7.6; 12.7; 12.7; 7.6; 7.6; 7.6; 10.2; 10.2];
E = 0.81;
for i = 1:length(h)
Cw(i) = h(i) - 2*(tf(i)) - 2*(r(i));
c_w(i) = Cw(i)/(tw(i));
if c_w(i) < 72*E
T1{i} = "Web is class 1";
else
T1{i} = "Web is not class 1";
end
Cf(i) = b(i)/2 - tw(i)/2 - r(i);
c_f(i) = Cf(i)/tf(i);
if c_f(i) < 9*E
T2{i} = "Flange is class 1";
elseif c_f(i) < 10*E
T2{i} = "Flange is class 2";
else
T2{i} = "Section is Class 3 or 4";
end
end
Table = table(c_w.',c_f.',T1.',T2.');
disp(Table)
4 commentaires
VBBV
le 27 Mar 2024
Modifié(e) : VBBV
le 27 Mar 2024
Section = ['254 x 254 x 73';'254 x 146 x 31';'254 x 146 x 31';'254 x 254 x 73';'254 x 254 x 73';'152 x 152 x 51';'152 x 152 x 51';'152 x 152 x 51';'203 x 203 x 46';'203 x 203 x 52'];
h = [254.1; 251.4; 251.4; 254.1; 254.1; 170.2; 170.2; 170.2; 203.2; 206.2];
b = [254.6; 146.1; 146.1; 254.6; 254.6; 157.4; 157.4; 157.4; 203.6; 204.3];
tw = [8.6; 6.00; 6.00; 8.6; 8.6; 11.00; 11.00; 11.00; 7.2; 7.9];
tf = [14.2; 8.6; 8.6; 14.2; 14.2; 15.7; 15.7; 15.7; 11.00; 12.5];
r = [12.7; 7.6; 7.6; 12.7; 12.7; 7.6; 7.6; 7.6; 10.2; 10.2];
E = 0.81;
for i = 1:length(h)
Cw(i) = h(i) - 2*(tf(i)) - 2*(r(i));
c_w(i) = Cw(i)/(tw(i));
if c_w(i) < 72*E
T1{i} = "Web is class 1";
fprintf(' ')
fprintf('\nc_w section')
fprintf('------------------------------------')
fprintf('%2.2d\t %s\n',c_w(i),T1{i})
else
T1{i} = "Web is not class 1";
fprintf('%2.2d\t %s\n',c_w(i),T1{i})
end
Cf(i) = b(i)/2 - tw(i)/2 - r(i);
c_f(i) = Cf(i)/tf(i);
if c_f(i) < 9*E
T2{i} = "Flange is class 1";
fprintf(' ')
fprintf('\nc_f section')
fprintf('-----------------------------------')
fprintf('%2.2d\t %s\n',c_f(i),T2{i})
elseif c_f(i) < 10*E
T2{i} = "Flange is class 2";
fprintf('%2.2d\t %s\n',c_f(i),T2{i})
else
T2{i} = "Section is Class 3 or 4";
fprintf('%2.2d\t %s\n',c_f(i),T2{i})
end
end
% Table = table(c_w.',c_f.',T1.',T2.');
% disp(Table)
Voir également
Catégories
En savoir plus sur Call Web Services from MATLAB Using HTTP dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!