Mirror of countourf on X, Y axis

4 ビュー (過去 30 日間)
ayoub
ayoub 2014 年 8 月 7 日
コメント済み: Sara 2014 年 8 月 7 日
Hello everyone,
I'm working on 2d unsteady heat transfer modeling using Fortran. i have my results (temperature field) but only on 1/4 of my rectangel because i have (symetrical Boundary conditions).
I drew the results using matlab (countourf (x,y,z...), z=temperature, on 1/4 of the rectangle. can anyone of you explain me how to draw the temperature field on the entire rectangle ?? because it's symetrical, i would like to use mirror effect on x y axis. (-x-y) (-x+y) (x-y)
i don't wanna to multiply dimension of each vector *4, i tried it, it worked but very very slow.
there is my code : close all; clear;clc; a=load('new4.txt'); N=100
x=a(:,1); x coord y=a(:,2); y coord z=a(:,3);% temperature vetor
methode='v4'; Xmin = min(x); Xmax = max(x); Ymin = min(y); Ymax = max(y);
X =linspace(Xmin,Xmax,N); Y =linspace(Ymax,Ymin,N);
[X,Y] = meshgrid(X,Y);
Z = griddata(x,y,z,X,Y, methode); [c]=contourf(+X,+Y,Z,10); .
Thank you in advance.

採用された回答

Sara
Sara 2014 年 8 月 7 日
Look at the following example. If x and y start from 0, you can repeat the contour command 4 times. otherwise, you need to translate your coords.
x = 0:0.1:10;
y = -0:0.1:10;
[x,y]= meshgrid(x,y);
z = x.^2+y.^2;
figure
hold on
contourf(x,y,z)
contourf(-x,y,z)
contourf(x,-y,z)
contourf(-x,-y,z)
xlim([-10 10])
ylim([-10 10])
  2 件のコメント
ayoub
ayoub 2014 年 8 月 7 日
Thank you,
I did it finally figure
hold on %X =linspace(Xmin,Xmax,N); %Y =linspace(Ymax,Ymin,N);
[X,Y] = meshgrid(X,Y);
Z = griddata(x,y,z,X,Y, methode);
[c]=contourf(+X,-Y,Z,10); [c]=contourf(+X,-Y,Z,10); [c]=contourf(-X,-Y,Z,10); [c]=contourf(-X,+Y,Z,10); [c]=contourf(+X,+Y,Z,10);
axis equal tight
but the grid is gone :(. why?
Sara
Sara 2014 年 8 月 7 日
Add this at the end
set(gca,'layer','top');
grid on

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

その他の回答 (0 件)

カテゴリ

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