%% Drucker–Prager clear all; clc; A1=286.243; A2=1.407; A3=-4.035; A0=300; fai=20; for m=1:1:70 %长度 I1(m)=m*1; % I1=10; i=1; R(i)=0; %Increase radius to get failure for j=1:1:62 theta(j,m)=-pi/6+pi/30*(j-1); while fail(fai,I1,R,theta,i,j,m)<0 i = i+1; R(i)=R(i-1)+0.5; end Rf(j,m)=R(i); sig1(j,m)=I1(m)/3+sqrt(2/3)*Rf(j,m)*sin(theta(j)+2/3*pi); sig2(j,m)=I1(m)/3+sqrt(2/3)*Rf(j,m)*sin(theta(j)); sig3(j,m)=I1(m)/3+sqrt(2/3)*Rf(j,m)*sin(theta(j)-2/3*pi); i=10; R(i)=0; end end %% % close all % subplot(1,2,1); figure(1) mesh(sig1,sig2,sig3,'EdgeColor','b'); hold on view([20,5]); axis on; axis equal; set(gca,'Fontsize',15,'FontName','Times new Roman'); set(get(gca,'XLabel'),'FontSize',18,'FontName','Times new Roman'); set(get(gca,'YLabel'),'FontSize',18,'FontName','Times new Roman'); % subplot(1,2,2); % polar(theta,Rf,'b'); % axis equal; 将这段代码的循环I1与m分离
时间: 2023-12-17 18:05:22 浏览: 25
可以将循环I1与m分离,如下所示:
```matlab
clear all;
clc;
A1=286.243;
A2=1.407;
A3=-4.035;
A0=300;
fai=20;
% 定义长度范围
length_range = 1:1:70;
for m = length_range % 遍历长度范围
I1(m) = m*1; % 设置当前长度
end
I1 = 10; % 将 I1 的循环去掉
i=1;
R(i)=0; %Increase radius to get failure
% 遍历角度范围
for j=1:1:62
theta(j,:) = -pi/6+pi/30*(j-1); % 设置当前角度
while fail(fai,I1,R,theta,i,j,m)<0
i = i+1;
R(i)=R(i-1)+0.5;
end
Rf(j,:) = R(i);
sig1(j,:) = I1/3+sqrt(2/3)*Rf(j,:)*sin(theta(j)+2/3*pi);
sig2(j,:) = I1/3+sqrt(2/3)*Rf(j,:)*sin(theta(j));
sig3(j,:) = I1/3+sqrt(2/3)*Rf(j,:)*sin(theta(j)-2/3*pi);
i=10;
R(i)=0;
end
% 绘制图像
figure(1)
mesh(sig1,sig2,sig3,'EdgeColor','b');
hold on
view([20,5]);
axis on;
axis equal;
set(gca,'Fontsize',15,'FontName','Times new Roman');
set(get(gca,'XLabel'),'FontSize',18,'FontName','Times new Roman');
set(get(gca,'YLabel'),'FontSize',18,'FontName','Times new Roman');
```