Making 10 2D slices out of 3D plot
22 次查看(过去 30 天)
显示 更早的评论
Can i make the first plot like the second plot but at fixed variable which means i want to make 10 2D slices of 3D by fixing b (beta) at a constant value:(0, .1, .2, .........1).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153416/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153417/image.png)
This my code
clear
close
clc
%x=[x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11),x(12)]; % angles;
lb=[0,0,0,0,0,0,0,0,0,0,0,0];
ub=[pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi];
%x0=[pi/8;0;pi/3;0;0.7*pi;.6;0;pi/2;.5;0;pi/4;0];
options = optimoptions(@fmincon,'TolX',10^-12,'MaxIter',1500,'MaxFunEvals',10^8,'Algorithm','sqp','TolFun',10^-8);
a=0:0.01:1;
%b=0:0.1:1;
b=.5;
%w=NaN(length(a),length(b));
w=NaN(size(a));
%ww=NaN(length(a),length(b));
ww=NaN(size(a));
for k=1:50
x0=rand([1,12]).*ub*.9986;%7976
for i=1:length(a)
%for j=1:length(b)
chelp=1-(a(i)^2)-(b^2);
if (chelp>0 || chelp==0)
c=sqrt(chelp);
[~,fval]=fmincon(@(x)GHZsb2(x,a(i),b,c),x0,[],[],[],[],lb,ub,[],options);
w(i)=sqrt(-fval);
else
w(i)=nan;
end
ww=max(w,ww);
end
end
%end
%yy=b.^2;
xx=a.^2;
%surface(h,y,ww)
%view(3)
%meshc(xx,yy,ww)
plot(xx,ww)
grid on
ylabel('\fontname{Times New Roman} S_{max}(\Psi_{G})')
xlabel('\fontname{Times New Roman}\alpha^2')
%axis([0 2*pi -1.5 1.5])
%ylabel('\fontname{Times New Roman}\beta^2')
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!