我已将Python代码中的以下公式转换为MATLAB代码。 是不是?
公式在这里:
Python代码:
self.Amax = 0.01
self.Smax = 1e5
x1 = x[:, 0]
x2 = x[:, 1]
y = x[:, 2]
f1 = x1 * anp.sqrt(16 + anp.square(y)) + x2 * anp.sqrt((1 + anp.square(y)))
sigma_ac = 20 * anp.sqrt(16 + anp.square(y)) / (y * x1)
sigma_bc = 80 * anp.sqrt(1 + anp.square(y)) / (y * x2)
f2 = anp.max(anp.column_stack((sigma_ac, sigma_bc)), axis=1)
g1 = f2 - self.Smax
我的Matlab代码:
Amax = 0.01;
Smax = 10^5;
x1 = x(:,1);
x2 = x(:,2);
y = x(:,3);
f(1,:) = x1 .* sqrt(16 + (y).^2) + x2 .* sqrt((1 + (y).^2));
sigma_ac = 20 .* sqrt(16 + (y).^2) ./ (y .* x1);
sigma_bc = 80 .* sqrt(1 + (y).^2) ./ (y .* x2);
Sigma = [sigma_ac, sigma_bc];
f(2,:) = max(Sigma,[],2);
g = f - Smax;