我正在尝试制作三个列向量的图,以便制作三维曲面图,但输出只是一个不连续的线。任何帮助表示赞赏,代码如下。为混乱的变量名提前道歉。
co = 29;
BF = .0446;
WPW = 50;
E = [0:0.01:2]; //sets up a column vector
p = [];
WBR =[];
w = [];
t = 8.64E13;
delta = [0:0.5:100];
R =[];
DeltaMu = [];
Total = [];
//begin program iteration through k; change "k" value in for loop to change
//the number of iterations the program runs over, and thus the amount
//of degrees of freedom
k = 200;
for i = 1:k,
I = 12.5 + 0.167*i;
mu = I/co;
sigma = .11*mu;
cdf = cdfnor("PQ", E, mu*ones(E), sigma*ones(E));
n = 201; // variable over which the loop is iterated
pdf = zeros(201,1); // sets up an appendable matrix of all zeros
temp = 0; //initiates a temporary integer variable
while n > 1,
temp = cdf(n) - cdf(n-1); //assigns a value to the temp variable every pass
pdf(n) = temp; //assigns the temp value to the nth slot in the
//column vector, works through the matrix backwards
n = n-1; //iterates the while loop on n
end //breaks from while loop after n hits 1
temp = cdf(n);
pdf(n) = temp;
n = 201;
while n > 1,
a = exp(-WPW*exp(-delta(n)*(1-E)));
n = n-1;
end
n = 201; // variable over which the loop is iterated
prob = zeros(201,1); // sets up an appendable matrix of all zeros
temp = 0; //initiates a temporary integer variable
while n > 1,
temp = a(n)*pdf(n); //assigns a value to the temp variable every pass
prob(n) = temp; //assigns the temp value to the nth slot in the
//column vector, works through the matrix backwards
n = n-1; //iterates the while loop on n
end //breaks from while loop after n hits 1
WBR(i) = sum(prob)*BF
w(i) = mu
end
//begin program iteration through k; change "k" value in for loop to change
//the number of iterations the program runs over, and thus the amount
//of degrees of freedom
k = 200;
for i = 1:k,
mu = .5*i;
sigma = .1*mu;
cdf = cdfnor("PQ", delta, mu*ones(delta), sigma*ones(delta));
n = 201; // variable over which the loop is iterated
pdf = zeros(201,1); // sets up an appendable matrix of all zeros
temp = 0; //initiates a temporary integer variable
while n > 1,
temp = cdf(n) - cdf(n-1); //assigns a value to the temp variable every pass
pdf(n) = temp; //assigns the temp value to the nth slot in the
//column vector, works through the matrix backwards
n = n-1; //iterates the while loop on n
end //breaks from while loop after n hits 1
temp = cdf(n);
p = 1-(exp(-t*exp(-delta)));
n = 201; // variable over which the loop is iterated
Psw = zeros(201,1); // sets up an appendable matrix of all zeros
temp = 0; //initiates a temporary integer variable
while n > 1,
temp = p(n)*pdf(n); //assigns a value to the temp variable every pass
Psw(n) = temp; //assigns the temp value to the nth slot in the
//column vector, works through the matrix backwards
n = n-1; //iterates the while loop on n
end //breaks from while loop after n hits 1
R(i) = sum(Psw)
DeltaMu(i) = mu
end
n = 200;
while n > 1,
Total(n) = WBR(n) + R(n);
n = n-1;
end
xdel(winsid()); //close any open graphs
plot3d(WBR, R, Total)
答案 0 :(得分:1)
要使用plot3d绘制曲面,您需要:
玩具示例:
SELECT hour( from_unixtime( epoch ) ) div 6 * 6, hour( from_unixtime( epoch ) ) div 6 * 6 + 5, count( num )
FROM `logs`
WHERE username = 'bob'
AND from_unixtime( epoch )
BETWEEN date_sub( now( ) , INTERVAL 1 week )
AND now( )
GROUP BY hour( from_unixtime( epoch ) ) div 6;
从三列向量制作表面图在数学上是不合理的。您可以使用它们绘制参数曲线,该曲线使用三个向量来表示x,y,z坐标:
plot3d([1 2 3], [2 3 4], [0 1 2; 2 3 2; 0 2 1])
根据您的数据,由于数组的动态范围很大,结果仍然不引人注意。考虑以对数标度绘图。