I received a request of how to create a rectangular surface.
This post is about plot3d(.) function, which I use to create surfaces in Scilab: http://usingscilab.blogspot.com.br/2009/06/plot-3d-surface.html
Now, look plot3d(.) has three arguments: x, y, and z, being the first two ones vectors and the last one is a matrix.
For a surface that x and y are in set [0, 10] and z is in set [0, 1], take the following code:
-->x = 0:10;
-->y = 0:10;
-->z = zeros(length(x), length(y)); // z matrix is initialized with zeros
-->z(($/4):(3*$/4),($/4):(3*$/4)) = 1 // a square in the matrix is set to 1
z =
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
-->plot3d(x, y, z); // shows the 3d graphic with x, y, and z components
The generated image is the following.
I wish this example has been helpful.
Obs.: for creating a cube, or parallelogram, plot3d2(.) function is more recommended: http://usingscilab.blogspot.com.br/2012/09/plot3d2-creating-cube.html
This post is about plot3d(.) function, which I use to create surfaces in Scilab: http://usingscilab.blogspot.com.br/2009/06/plot-3d-surface.html
Now, look plot3d(.) has three arguments: x, y, and z, being the first two ones vectors and the last one is a matrix.
For a surface that x and y are in set [0, 10] and z is in set [0, 1], take the following code:
-->x = 0:10;
-->y = 0:10;
-->z = zeros(length(x), length(y)); // z matrix is initialized with zeros
-->z(($/4):(3*$/4),($/4):(3*$/4)) = 1 // a square in the matrix is set to 1
z =
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 1. 1. 1. 1. 1. 1. 1. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
-->plot3d(x, y, z); // shows the 3d graphic with x, y, and z components
The generated image is the following.
I wish this example has been helpful.
Obs.: for creating a cube, or parallelogram, plot3d2(.) function is more recommended: http://usingscilab.blogspot.com.br/2012/09/plot3d2-creating-cube.html
No comments:
Post a Comment