将2D代码/图转换为3D代码/图。
我可以使用下面的代码创建2D图,从而生成下面的图。但是如何将2D图转换为3D图。我尝试使用meshgrid进行此操作,但它创建的绘图不在3D模式中,并且曲线不再显示在绘图中。我在下面包括了我正在使用的2D代码以及它产生的绘图。同样在底部,我显示了3D代码以及它最终产生的不正确的图。
%---2D working code
clear all,clf reset,tic,clc, close all,
S=[15.3039,10.3612,7.9153,6.3793,5.3019,4.4955,3.8656,3.3584,2.9405,2.5903,2.2926,2.0367,1.8146,1.6204,1.4496,1.2983,1.1638,1.04377,.93622,.83959,.75256,.67401,.603,.53871,.48045,.42762,.37969,.33619,.29673,.26094,.22852,.19917,.17265,.14874,.12722,.10791,.090664,.075316,.061733,.049793,.039383,.030399,.0227475,.0163414,.0111008,.0069525,.0038286,.0016664,.0004081];
x = linspace(0,1,100);
T = 1.12;
for bb = 1:length(S)
y1=exp(log(1-x.^(S(1,bb)*T))/(S(1,bb)*T)); %right to left top to bottom
hold on
plot(x,y1,'r')
end
我尝试将网格与一起使用的代码,但它不是3D模式,并且曲线图案不再存在。
%---3D non-working code
clear all,clf reset,tic,clc, close all,
S=[15.3039,10.3612,7.9153,6.3793,5.3019,4.4955,3.8656,3.3584,2.9405,2.5903,2.2926,2.0367,1.8146,1.6204,1.4496,1.2983,1.1638,1.04377,.93622,.83959,.75256,.67401,.603,.53871,.48045,.42762,.37969,.33619,.29673,.26094,.22852,.19917,.17265,.14874,.12722,.10791,.090664,.075316,.061733,.049793,.039383,.030399,.0227475,.0163414,.0111008,.0069525,.0038286,.0016664,.0004081];
x = linspace(0,1,10);
T = 1.12;
[SS,xx]=meshgrid(S,x); %create meshgrid data
for bb = 1:length(S)
z=exp(log(1-xx.^(SS*T))/(SS*T)); %right to left top to bottom
hold on
plot(xx,SS,z,'r')
end
PS:我正在使用与Matlab类似的Octave 4.2.2。