0

I am trying to make a plot of three column vectors right now in order to make a three dimensional surface plot, but the output is just a discontinuous line. Any help is appreciated, code is below. Apologies in advance for the confusing variable names.

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)     

1 Answer 1

1

To plot a surface with plot3d, you need:

  • a vector of x-values
  • a vector of y-values
  • a matrix of z-values, where the (i,j) entry will determine the height over the point (x(i),y(j))

Toy example:

plot3d([1 2 3], [2 3 4], [0 1 2; 2 3 2; 0 2 1])

plot

There is no mathematically reasonable to make a surface plot from three column vectors. What you could do with them is draw a parametric curve, which uses three vectors for x,y,z coordinates:

param3d(WBR, R, Total)   

With your data, the result is still unspectacular because of the high dynamic range with the arrays. Consider plotting on the logarithmic scale.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.