Tricky questions

classic Classic list List threaded Threaded
1 message Options
Tomaz Kostanjevec Uni Mb Tomaz Kostanjevec Uni Mb
Reply | Threaded
Open this post in threaded view
|

Tricky questions

Hello,

 

From Slovenia – big problem J. Waiting for answer.

 

In file is added problem.

 

Questions are:

//Question 1: how to draw lines for Z axes (represent time) out to matrix data?

//Question 2: how to draw spline3d on the surface of dawned graph?

//Question 3: - hardest - how to draw multidimensional trend of that graph with spline3d in Z direction?

// For all the answers - congratulations (I spend 20 hours on that)

 

Best regards,

Tomaz

 

Algorithm is that:

 

function [xx,yy,zz]=graf3d(A)

[n,m]=size(A) // matrix A

 

 

X=zeros(4,(n-1)*m)

 

    for i=1:(n-1)

      for j=1:(m-1) //posebej za j=m

        X(1,(i-1)*m+j)= A(i,j)*cos((j-1)*2*%pi/m)

        X(2,(i-1)*m+j)= A(i,j+1)*cos(j*2*%pi/m)

        X(3,(i-1)*m+j)= A(i+1,j)*cos((j-1)*2*%pi/m)

        X(4,(i-1)*m+j)= A(i+1,j+1)*cos(j*2*%pi/m)

      end

    end

 

    for i=1:(n-1)

        X(1,i*m)= A(i,m)*cos((m-1)*2*%pi/m)

        X(2,i*m)= A(i,1)*cos(0)

        X(3,i*m)= A(i+1,m)*cos((m-1)*2*%pi/m)

        X(4,i*m)= A(i+1,1)*cos(0)  

    end 

 

Y=zeros(4,(n-1)*m)

 

    for i=1:(n-1)

        for j=1:(m-1) // posebej za j=m

          Y(1,(i-1)*m+j)= A(i,j)*sin((j-1)*2*%pi/m)

          Y(2,(i-1)*m+j)= A(i,j+1)*sin(j*2*%pi/m)

          Y(3,(i-1)*m+j)= A(i+1,j)*sin((j-1)*2*%pi/m)

          Y(4,(i-1)*m+j)= A(i+1,j+1)*sin(j*2*%pi/m)

        end

    end

 

    for i=1:(n-1)

      Y(1,i*m)= A(i,m)*sin((m-1)*2*%pi/m)

      Y(2,i*m)= A(i,1)*sin(0)

      Y(3,i*m)= A(i+1,m)*sin((m-1)*2*%pi/m)

      Y(4,i*m)= A(i+1,1)*sin(0)  

    end 

 

 

Z=zeros(4,(n-1)*m)

 

  for i=1:(n-1)

    for j=1:m

      Z(1,(i-1)*m+j)= i

      Z(2,(i-1)*m+j)= i

      Z(3,(i-1)*m+j)= i+1

      Z(4,(i-1)*m+j)= i+1

    end

  end

 

xx=X

yy=Y

zz=Z

 

f=plot3d(xx,yy,zz)

 

endfunction

 

A=[30    10           5             5             20           10           10           10

30           11           6             7             17           8             6             15

31           12           6             6             15           8             7             15

33           12           6             7             15           8             8             11

34           14           7             8             13           9             9             6

32           15           6             7             14           7             8             11

34           16           4             6             12           8             9             11

36           18           4             4             11           7             10           10

37           19           3             3             11           7             7             13

38           19           2             3             10           8             6             14

43           17           2             2             12           8             8             8]

xtitle("3D")

 

graf3d(A)


graf3d eng (1K) Download Attachment