How to make countour plot zoomed out

조회 수: 7 (최근 30일)
N/A
N/A 2020년 3월 11일
답변: Piyush Lakhani 2020년 3월 11일
For the following code, my plot displayed is zoomed in too far, so I can't view all of the area I would like to. How do I adjust this so I can see the whole thing.
The object in the plot is multiple squres inside of each other.
MATLAB CODE:
function HeatTransfer ()
%i=1;
%j=1;
k=3.1;
hi=85.0;
ho=12;
Ti=380;
To=15;
x=.0010;
y=.0010;
T=ones(21,14);
itermax=1000000;
iter=1;
%Interior Node
%while i<=21 && j<=14
while iter<itermax
for i=6:16
for j=5:10
T(i,j)=380;
end
end
for i=2:5
for j=2:13
T(i,j)=(T(i,j+1)+T(i,j-1)+T(i+1,j)+T(i-1,j))/4;
end
end
for i=6:16
for j=2:4 %|| j=11:13
T(i,j)=(T(i,j+1)+T(i,j-1)+T(i+1,j)+T(i-1,j))/4;
end
end
for i=6:16
for j=11:13
T(i,j)=(T(i,j+1)+T(i,j-1)+T(i+1,j)+T(i-1,j))/4;
end
end
for i=17:20
for j=2:13
T(i,j)=(T(i,j+1)+T(i,j-1)+T(i+1,j)+T(i-1,j))/4;
end
end
%Node @ External Corder
%for j=1 %|| j=14
% n=1;
T(1,1)=((T(i,j-1)+T(i-1,j))+2*ho*x*To/k)/(2*(ho*x/k+2));
%end
%for i=1
% for j=14
T(1,14)=((T(i,j-1)+T(i-1,j))+2*ho*x*To/k)/(2*(ho*x/k+2));
% end
%end
%for i=21
%for j=1 %|| j=14
T(21,1)=((T(i,j-1)+T(i-1,j))+2*ho*x*To/k)/(2*(ho*x/k+2));
%end
%end
%for i=21
%for j=14
T(21,14)=((T(i,j-1)+T(i-1,j))+2*ho*x*To/k)/(2*(ho*x/k+2));
%end
%end
%Node @ Plane Surface
%for i=1
for j=2:13
T(1,j)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*ho*x*To/k)/(2*(ho*x/k+2));
end
%end
for i=2:20
%for j=1 %|| j=14
T(i,1)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*ho*x*To/k)/(2*(ho*x/k+2));
%end
end
for i=2:20
%for j=14
T(i,14)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*ho*x*To/k)/(2*(ho*x/k+2));
%end
end
%if i==21
for j=2:13
T(21,j)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*ho*x*To/k)/(2*(ho*x/k+2));
end
%end
%Node @ Internal Corner
%for i=6
% for j=5 %|| j=10
T(6,5)=(2*(T(i-1,j)+T(i,j+1))+(T(i+1,j)+T(i,j-1))+2*hi*x*Ti/k)/(2*(3+hi*x/k));
%end
%end
%for i=6
% for j=10
T(6,10)=(2*(T(i-1,j)+T(i,j+1))+(T(i+1,j)+T(i,j-1))+2*hi*x*Ti/k)/(2*(3+hi*x/k));
% end
%end
%for i=16
% for j=5 %|| j=10
T(16,5)=(2*(T(i-1,j)+T(i,j+1))+(T(i+1,j)+T(i,j-1))+2*hi*x*Ti/k)/(2*(3+hi*x/k));
%end
%end
%for i=16
%for j=10
T(16,10)=(2*(T(i-1,j)+T(i,j+1))+(T(i+1,j)+T(i,j-1))+2*hi*x*Ti/k)/(2*(3+hi*x/k));
%end
%end
%Node at Internal Edge
for i=6:16
%for j=5 %|| j=10
T(i,5)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*hi*x*Ti/k)/(2*(hi*x/k+2));
%end
end
for i=6:16
T(i,10)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*hi*x*Ti/k)/(2*(hi*x/k+2));
%end
end
%for i=6 %|| i=16
for j=5:10
T(6,j)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*hi*x*Ti/k)/(2*(hi*x/k+2));
end
%end
%for i=16
for j=5:10
T(16,j)=(2*T(i-1,j)+T(i,j+1)+T(i,j-1)+2*hi*x*Ti/k)/(2*(hi*x/k+2));
end
iter=iter+1;
end
colormap(jet)
contour(T)
disp(T)
fprintf('minimum temperature=')
disp(min(T,[],'all'))
fprintf('maximum temperature=')
disp(max(T,[],'all'))
end

채택된 답변

Piyush Lakhani
Piyush Lakhani 2020년 3월 11일
Simplest way to doing this is by setting the axis limits.
Here i am just mentioning one example.
contour(T)
xlim([-20 20]) % Here -20 to 20 are x axis limit. As i can see you are plotting just 'T' your x data may be just index of data points, so might your limit start from 0 to number of data points.
ylim([-10 10]) % Similar to x also limit the y

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by