0

Hi If I have data like this e.g.

x=[1:1:7];
y=[5:-1:1]';
z=[NaN  NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN
0.955113030084974   0.948571658876062   0.942624899410361   NaN NaN NaN NaN
0.937493758208870   0.928392864395896   0.920119550965773   0.910466888808695   0.901586502842837   0.892741292179595   NaN
0.879644551679863   0.862126561405869   0.846200299426160   0.827622958701087   0.810531605135333   0.793507569055583   0.775604152867929
];

I'd like to generate a contourf (i.e. contourf(x,y,z);) plot that gets rid of the steps i.e. the result should be a smooth curve at the border.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
Ib_Ade
  • 1
  • 2
  • Hi, when I plot the data, it looks like a staircase function. I d like it to be a curve. – Ib_Ade Sep 04 '14 at 16:05
  • How can I past a figure here...I am new**** :) – Ib_Ade Sep 04 '14 at 16:05
  • Could you add the code that you used to plot the data? – Trogdor Sep 04 '14 at 16:10
  • x=[1:1:7]; y=[5:-1:1]'; z=[NaN,NaN,NaN,NaN,NaN,NaN,NaN;NaN,NaN,NaN,NaN,NaN,NaN,NaN;0.955113030084974,0.948571658876062,0.942624899410361,NaN,NaN,NaN,NaN;0.937493758208870,0.928392864395896,0.920119550965773,0.910466888808695,0.901586502842837,0.892741292179595,NaN;0.879644551679863,0.862126561405869,0.846200299426160,0.827622958701087,0.810531605135333,0.793507569055583,0.775604152867929;] – Ib_Ade Sep 04 '14 at 16:23

1 Answers1

0

You could use imagesc instead, but the reason that there are such harsh steps is that you don't have enough data points. To change that, one option is to interpolate more data points in between what you have.

x=[1:1:7];
y=[5:-1:1]';
z=[NaN  NaN NaN NaN NaN NaN NaN
    NaN NaN NaN NaN NaN NaN NaN
    0.955113030084974   0.948571658876062   0.942624899410361   NaN NaN NaN NaN
    0.937493758208870   0.928392864395896   0.920119550965773   0.910466888808695   0.901586502842837   0.892741292179595   NaN
    0.879644551679863   0.862126561405869   0.846200299426160   0.827622958701087   0.810531605135333   0.793507569055583   0.775604152867929];

xn = 1:.01:7;
yn = [5:-.01:1]';
zn = interp2(x,y,z,xn,yn);
imagesc(xn,yn,zn);
Trogdor
  • 1,346
  • 9
  • 16