フィルターのクリア

Change units for contour plot

2 ビュー (過去 30 日間)
Maryam
Maryam 2013 年 7 月 29 日
I am having a silly problem with my contour plot:
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.
For the 1st plot, my x and y locations were in ft. I want to change their dimensions to meters. What I did was to multiply all the locations by 0.3048. However, doing this, I am not getting exactly the previous contour that I had for ft. dimensions. The overall trend is somehow the same but I can see some irregularities in some locations. Anyone knows what can cause this problem?
I am using contourf function with "V4" method.
Thanks. Maryam

回答 (1 件)

Kelly Kearney
Kelly Kearney 2013 年 7 月 29 日
Are you explicitly defining which contour levels to plot? If you don't, the contour function automatically chooses which levels to plot, trying to get some nice round numbers. If you specify the levels, you should get the same plots:
[x,y,z] = peaks;
clev = -8:2:6;
subplot(2,2,1);
[c,h] = contour(x,y,z);
clabel(c,h);
title('ft, automatic');
subplot(2,2,2);
[c,h] = contour(x,y,z*0.3048);
clabel(c,h);
title('m, automatic')
subplot(2,2,3);
[c,h] = contour(x,y,z, clev);
clabel(c,h);
title('ft, explicit')
subplot(2,2,4);
[c,h] = contour(x,y,z*0.3048, clev*0.3048);
clabel(c,h);
title('m, explicit')
  2 件のコメント
Maryam
Maryam 2013 年 7 月 29 日
Hello Thanks. What does [x,y,z] = peaks; clev = -8:2:6; do? Sorry to ask basic questions.
Kelly Kearney
Kelly Kearney 2013 年 7 月 30 日
[x,y,z] = peaks was just a way to generate some sample data. The peaks function is included in Matlab specifically to demonstrate things like surf, mesh, contour, etc. And clev = -8:2:6 creates a vector (values between -8 and 6, in steps of 2), which I later use as the specific contour levels in the 3rd and 4th subplots.

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

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by