3 D Plots in Matlab
To create 3D plots , first of all we need to create 3 variables. x,y and z.
Create the x and y arrays:-
>> x=-3:0.25:3;>> y=-3:0.25:3;
Create the meshgrid:-
>> [X Y]=meshgrid(x,y);
Define:-
Z=sqrt(X.^2 + Y.^2);
mesh(X,Y,Z);
>>surf(X,Y,Z);
>>surf(X,Y,-Z);
>>waterfall(X,Y,Z):-
>>contour(x,y,z):
>>>> surfc(X,Y,Z):-
Now we arrive to the view part:
View is used to give the viewing angle of the plot. the syntax of the command is :-
view(azimuth,elevation);
where the azimuth is an angle measured in degrees in the x-y plane and is measured relative to the negative y axis and positive as always in the anti clockwise direction.
The elevation is the angle measured from the x-y plane in the direction of the z - axis.
default values are azimuth=-37.5 and elevation =35.
Here are the results of applying different views to the last plot:-
>> view(-65,30);
>> view(-37.5,40);
No comments:
Post a Comment