## How to get rid of extra contour lines?

Carly Svenvold

### Carly Svenvold (view profile)

さんによって質問されました 2016 年 8 月 24 日

### Carly Svenvold (view profile)

さんによって 編集されました 2016 年 9 月 2 日
I am plotting interpolated temperatures for a solar wall, and am encountering issues with contour lines. I end up with two sets, neither following where they should. I am also running into issues getting my second set of axes to line up, as well as general placement of everything on my figure. I've been scouring this forum for weeks and trying a bunch of different things, but nothing seems to work. Help is appreciated! I just want this graph to look nice. Partial code below.
[EDIT]- added the file necessary to reproduce graph, fixed notation
%%Average Cavity Temperature - Fine Mesh
% Location of Sensors
% 126" 418" 662"
% |--------------------|
% 120" | C3 | C5 | C2 |
% |--------------------|
% 27" | C1 | C6 | C4 |
% |--------------------|
% Create interpolated temp profile and average for each point in time
% Matrices Defining Sensor Locations
x = [126 418 662; 126 418 662];
y = [27 27 27; 120 120 120];
i=145; %this will change to a loop variable when I start running more graphs
c = [CalcData(i,9) CalcData(i,11) CalcData(i,8);...
CalcData(i,7) CalcData(i,12) CalcData(i,10)];
xq=[0:1:793];
yo=[0:1:156];
yz=zeros(1,637);
yq=horzcat(yo,yz);
% Interpolation Grid, Entire Wall
[X,Y]=ndgrid(xq,yq);
% Interpolated Cavity Temperature Profile
Cq=scatteredInterpolant(x(:),y(:),c(:));
C=Cq(X,Y);
%% THIS IS WHERE I NEED HELP
scrsz = get(groot,'ScreenSize');
figure1 = figure('Color',[1 1 1],'Position',[30 30 scrsz(3)*2/3 scrsz(4)*2/3])
axes1 = axes('Parent',figure1,'Position',[.1 .6 .6 .3]);
axis(axes1,'tight');
xlabel('Collector Width (in)','FontSize',12,'FontName','Times New Roman');
ylabel('Collector Height (in)','FontSize',12,'FontName','Times New Roman');
set(axes1,'BoxStyle','full','Layer','top','XTick',...
[0 100 200 300 400 500 600 700]);
axes2 = axes('Parent',figure1,'Position',[0.183666312433581 0.62531328320802 0.7 0.3]);
set(axes2,'Color','none','FontName','Times','FontSize',11,'XAxisLocation',...
'top','XTick',[0 0.25 0.5 0.75 1],'XTickLabel',{'0','5','10','15','20'},...
'YAxisLocation','right','YTick',[0 0.25 0.5 0.75 1],'YTickLabel',...
{'0','1','2','3','4'});
xlabel('Collector Width (m)');
ylabel('Collector Height (m)');
subplot(2,1,1,axes1)
hold(axes1,'on');
contourf(X,Y,C,'Parent',axes1)
tootle=sprintf('Cavity Temperature Profile in %cF - March 4th %d:%d',char(176),CalcData(i,4),CalcData(i,5));
title(tootle,'FontSize',14,'FontName','Times New Roman');
colormap('jet');
degF=sprintf('%cF',char(176));
degC=sprintf('%cC',char(176));
cb=colorbar('peer',axes1,'FontName','Times New Roman','Position',[0.88 0.62 0.02 0.28],'FontSize',12);
colortitlehandle=get(cb,'Title');
titlestring=sprintf('Temperature (%s)',degF);
set(colortitlehandle,'string',titlestring);

#### 0 件のコメント

サインイン to comment.

## 1 件の回答

2016 年 9 月 1 日

### Shruti Shivaramakrishnan (view profile)

2016 年 9 月 1 日

I tried executing your code to reproduce the issue, but noticed the following issues:
• The for loop for i ranging from 1 to 145 needs to be terminated
• The function CalcData(i,n) is missing.
Could you post the required function for others to be able to execute the code? Also, information on exactly what is the desired output and explanation of how you are trying to achieve it would be helpful for the community in answering your question.

Carly Svenvold

### Carly Svenvold (view profile)

2016 年 9 月 2 日
I've gone through and fixed the loop, and added the file necessary to recreate the graph shown. Thank you for your help!

サインイン to comment.

Translated by