Need half of my contour plot

Hello I have a contour of the pressures over a surface. Basically, I had vectors x and y which were locations on the surface and on each location, I had a value for pressure. I have a rectangular plot. I was wondering if there is a way to split my plot from the diagonal and show just the results for either upper or lower triangles?

 採用された回答

Kye Taylor
Kye Taylor 2013 年 7 月 18 日
編集済み: Kye Taylor 2013 年 7 月 18 日

0 投票

Check out the tril and triu functions. For example if you have data similar to
[x,y]= meshgrid(-1:.05:1);
z = x.^2+y.^2;
contour(x,y,z)
Try something like
zLowerTri = tril(z);
contour(x,y,zLowerTri)
Since contour plots with the origin at lower left instead of upper right, you may prefer either
zLowerTri = tril(z);
contour(x,y,zLowerTri)
axis ij
or
contour(x,y,fliplr(tril(fliplr(z))))

4 件のコメント

Maryam
Maryam 2013 年 7 月 18 日
Thank you very much for your response. Actually, it cuts the contour from another diagonal. Is there any way to do it for the other diagonal? Also, is there any way to show the deleted part in white?
Maryam
Maryam 2013 年 7 月 18 日
I used "contour(x,y,fliplr(tril(fliplr(z))))" and I got what I wanted. Thank you very much. I now need to Also, to show the deleted parts in white? Is there any way to do that? In the deleted area, my contour is all red which corresponds to the value=0 in my color map.
Pourya Alinezhad
Pourya Alinezhad 2013 年 7 月 19 日
use "nan" as i mentioned below to make that part invisible... functions you use {ex:tril(z)} replace the data values with zero,which itself could be a data!!!
Maryam
Maryam 2013 年 7 月 19 日
Thank you very much. I now have what I wanted.

サインインしてコメントする。

その他の回答 (1 件)

Pourya Alinezhad
Pourya Alinezhad 2013 年 7 月 18 日
編集済み: Pourya Alinezhad 2013 年 7 月 18 日

0 投票

hello maryam, run following lines of code.
x=0:0.1:10;
y=x;
j=1;
z=meshgrid(x,y);
h=ones(length(x),length(x))*nan;
for i=1:length(x)
for j=1:length(y)
if i>j
h(i,j)=z(i,j);
end
end
end
surf(sin(h)./sqrt(h))
figure
contourf(sin(h)./sqrt(h))

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by