i'm having issues using format short in my code
40 ビュー (過去 30 日間)
古いコメントを表示
I want to limit the number of decimal points my outputs have for an entire code section. I tried using "format short" at the top of my section, but find that my outputs at the end of calculations have 30+ digits attached. The values are correct, i just want to pare them down without having to use the vpa command on every one.
2 件のコメント
回答 (1 件)
Cris LaPierre
2021 年 11 月 18 日
syms t
digits(4)
E = 9000; %MPa
v = 0.36;
t = 152e-5;
I = eye(3);
F = t*[.1 -.171 0;
.063 .062 0;
0 -.045 -.149];
Ft = transpose(F);
strain = .5*(F+Ft);
rotation = .5*(F-Ft);
epskk = sum(diag(strain));
delta = 0;
for i = 1:length(strain)
for j = 1:length(strain)
if i==j
delta = 1;
else
delta = 0;
end
sig(i,j) = (E/(1+v))*(strain(i,j) + (v/(1-2*v))*epskk*delta);
end
disp(sig)
end
sigt = transpose(sig);
n = [0.8 -0.6 0];
nt = transpose(n);
T = sigt*nt;
signn = dot(T,n); %this is in MPa
T_normal = signn*nt
T_shear = T-T_normal
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!