How to order matrix
3 views (last 30 days)
Show older comments
Hello :)
I want to arrange in a matrix, for example that's what I got in the software of command window
The strain tensor is
1.0e-04 *
0.0546 -0.1875 0.0625
-0.1875 0.1792 0.3125
0.0625 0.3125 -0.1324
How can do like this : [5.45*10^-6 -1.87*10^-5 .......] (without 1.0e-04 *)
Thanks for the helpers
My code:
clc;
clear;
sigma=input('Insert normal stresses[Mpa] and shear stresse[Mpa] of the cauchy stress tensor:');
format short %fixed-decimal format with a total of 4 digits
sigma_xx=sigma(1,1);
tau_xy=sigma(1,2);
tau_xz=sigma(1,3);
tau_yx=sigma(2,1);
sigma_yy=sigma(2,2);
tau_yz=sigma(2,3);
tau_zx=sigma(3,1);
tau_zy=sigma(3,2);
sigma_zz=sigma(3,3);
disp('The matrix is'); disp(sigma);
Metal = input('Insert type of a metal material:','s');
switch Metal
case 'AISI1020'
S_y = 427;
G = 80000;
v = 0.29;
E = 207000;
case 'Alloy6061-T6'
S_y = 276;
G = 26000;
v = 0.33;
E = 69,000;
case 'SAE4340'
S_y = 910;
G = 83000;
v = 0.29;
E = 214000;
end
epsilon_x=(1/E)*((sigma_xx)-v*((sigma_yy)+(sigma_zz))) ;
epsilon_y=(1/E)*((sigma_yy)-v*((sigma_zz)+(sigma_xx))) ;
epsilon_z=(1/E)*((sigma_zz)-v*((sigma_xx)+(sigma_yy))) ;
gamma_xy=(tau_xy)/(2*G) ;
gamma_xz=(tau_xz)/(2*G) ;
gamma_yz=(tau_yz)/(2*G) ;
gamma_yx=gamma_xy;
gamma_zx=gamma_xz;
gamma_zy=gamma_yz;
epsilon=zeros(3,3);
epsilon(1,1)=epsilon_x;
epsilon(1,2)=gamma_xy;
epsilon(1,3)=gamma_xz;
epsilon(2,1)=gamma_yx;
epsilon(2,2)=epsilon_y;
epsilon(2,3)=gamma_yz;
epsilon(3,1)=gamma_zx;
epsilon(3,2)=gamma_zy;
epsilon(3,3)=epsilon_z;
disp('The strain tensor is'); disp(epsilon)
0 Comments
Accepted Answer
Cris LaPierre
on 13 Nov 2020
Edited: Cris LaPierre
on 13 Nov 2020
1 Comment
Cris LaPierre
on 13 Nov 2020
As an example
epsilon=1.0e-04 *[
0.0546 -0.1875 0.0625
-0.1875 0.1792 0.3125
0.0625 0.3125 -0.1324];
fprintf('%g %g %g\n',epsilon)
More Answers (1)
Setsuna Yuuki.
on 13 Nov 2020
Edited: Setsuna Yuuki.
on 13 Nov 2020
You can change the numeric format in Configuration.
Change Numeric format in command Window.
I hope it helps
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/413273/image.jpeg)
See Also
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!