Reputation: 253
It is necessary for me that plot a rectangular in MATLAB by contour. But when I plot this, the figure is like square and no rectangular.
In fact the length of X axis and Y axis are true, but figure is not rectangular.
How could I find a rectangular figure?
Once before I needed to plot a n eliptical by countour and it was like circle, by setting axes([xmin xmax ymin ymax])
this problem was solved but know this command do not work.
Here is my code u0
,x
,y
are 3 vectors of length nx*ny
. and nx
and ny
are the number of points in x axis and y axis.
figure
for i=1:ny
z(i,:)=u0((i-1)*nx+1:i*nx);
x1(i,:)=x((i-1)*nx+1:i*nx);
y1(i,:)=y((i-1)*nx+1:i*nx);
end;
cMap = [0.45 0.6 0.65;1 1 1]; % [green;yellow] on rgb-color
colormap(cMap);
axis equal
contourf(x1,y1,z,'LineColor','none')
colorbar
Let 's=0:0.1:0.2' and 'x=repmat(s,1,ny)' and 'd=0:0.1:1', 'y=repmat(d,1,nx)' 'u0=x+y'
Upvotes: 1
Views: 2151
Reputation: 6424
I think the problem is the size of the vector you are using. Check out this example:
x = linspace(0,2,20);
y = linspace(0,1,10);
z = meshgrid(x,y);
contourf(x,y,z,20);
axis equal
it gives the following result:
Now if we check the sizes:
>> size(x)
ans =
1 20
>> size(y)
ans =
1 10
>> size(z)
ans =
10 20
if the size of x vector is equal to the size of the y vector it gives you a square obviously! in your case first check the size of x1, y1, z just before using the contourf an make sure that you are using axis equal after that.
Upvotes: 1