将八度/ matlab方程从2D转换为3D图

时间:2019-05-16 16:16:04

标签: matlab octave

将2D代码/图转换为3D代码/图。

我可以使用下面的代码创建2D图,从而生成下面的图。但是如何将2D图转换为3D图。我尝试使用meshgrid进行此操作,但它创建的绘图不在3D模式中,并且曲线不再显示在绘图中。我在下面包括了我正在使用的2D代码以及它产生的绘图。同样在底部,我显示了3D代码以及它最终产生的不正确的图。

Formula image

%---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

2D correct plot of equation

我尝试将网格与一起使用的代码,但它不是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

产生不正确的3D图像代码 enter image description here

PS:我正在使用与Matlab类似的Octave 4.2.2。

1 个答案:

答案 0 :(得分:1)

我建议使用类似var pauseWheel = false; $(window).on('mousewheel', function(event) { if(pauseWheel) { event.preventDefault(); } else { pauseWheel = true; setTimeout(function(){ pauseWheel = false; }, 1000); } } 的内容:

surf

给出:

enter image description here