24小时热门版块排行榜    

查看: 1196  |  回复: 18
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

wzp0098

木虫 (著名写手)

[求助] 用matlab 画三维图,请高手指教. 已有2人参与

程序如下,可是没有办法运行,请高手指教,重谢。
W=-3:0.1:3;K=-3:0.1:3i;V=-3:0.1:3;
P = [];
for n=1:length(W);
         Ky=W(n);
     for m=1:length(K);
         Kx=K(m);
          for v=1:length(V);
              Kz=V(v);
        w = 1;
        K2 = K1+2*w; x = 2*(sin(Kx)+sin(Ky));
        r1 = 8; r2 = 0.001*r1; T = 3*sin(Kz);
        A=[  -r1   r2-r1  -i*x      i*x      0           0       0              0;
                  0    -r2       0       0       0           0      i*T           -i*T;
           -2*i*x  -i*x -r1-i*K1*0.5 0     -i*T          0       0              0;
                2*i*x  i*x       0  -r1+i*K1*0.5 0          i*T      0              0;
                  0     0      -i*T      0 -r2-i*(K1+K2)*0.5 0      i*x             0;
                  0     0        0      i*T      0 -r2+i*(K1+K2)*0.5 0             -i*x;
                 i*T 2*i*T       0       0      i*x          0 -r2-r1+i*(K1-K2)*0.5 0;
                -i*T -2*i*T      0       0       0         -i*x      0 -r2-r1-i*(K1-K2)*0.5];
        B = [-r1;0;-i*x;i*x;0;0;i*T;-i*T];
        Y = A\B;
    P(n, m, v) = imag(Y(3)); % <---------------------------P向量中的元素赋值
          end
    end
end
[X,Y,Z]=meshgrid(W,K,V);
surf(X,Y,Z,P);
shading interp
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
wzp0098: 金币+70, 有帮助, 谢谢! 2015-01-02 09:19:29
CODE:
function slice_4D
W=-3:0.1:3;K=-3:0.1:3;V=-3:0.1:3;
P = [];
for n=1:length(W);
          Ky=W(n);
      for m=1:length(K);
          Kx=K(m);
           for v=1:length(V);
               Kz=V(v);
         w = 1;K1=0;
         K2 = K1+2*w; x = 2*(sin(Kx)+sin(Ky));
         r1 = 8; r2 = 0.001*r1; T = 3*sin(Kz);
         A=[  -r1   r2-r1  -i*x      i*x      0           0       0              0;
                   0    -r2       0       0       0           0      i*T           -i*T;
            -2*i*x  -i*x -r1-i*K1*0.5 0     -i*T          0       0              0;
                 2*i*x  i*x       0  -r1+i*K1*0.5 0          i*T      0              0;
                   0     0      -i*T      0 -r2-i*(K1+K2)*0.5 0      i*x             0;
                   0     0        0      i*T      0 -r2+i*(K1+K2)*0.5 0             -i*x;
                  i*T 2*i*T       0       0      i*x          0 -r2-r1+i*(K1-K2)*0.5 0;
                 -i*T -2*i*T      0       0       0         -i*x      0 -r2-r1-i*(K1-K2)*0.5];
         B = [-r1;0;-i*x;i*x;0;0;i*T;-i*T];
         Y = A\B;
     P(n, m, v) = imag(Y(3)); % <---------------------------P向量中的元素赋值
           end
     end
end
[X,Y,Z]=meshgrid(W,K,V);
slice(X,Y,Z,P,[-2.5 0 2.5],0,[-2 2])

用matlab 画三维图,请高手指教.
untitled.jpg

» 本帖已获得的红花(最新10朵)

The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
8楼2014-12-31 09:37:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
10楼: Originally posted by wzp0098 at 2015-01-03 22:40:00
我想看到附件一样的图,请指教. 是否能用griddata3?

@RN1%DO4A1R%H5DNB`$PFQI.png
...

你想看的是否是P关于W;K;V的等值面?
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
11楼2015-01-03 23:33:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
wzp0098: 金币+60, ★★★很有帮助 2015-01-04 16:47:10
CODE:
function slice_4D
W=-3:0.05:3;K=-3:0.05:3;V=-3:0.05:3;
P = [];
for n=1:length(W);
          Ky=W(n);
      for m=1:length(K);
          Kx=K(m);
           for v=1:length(V);
               Kz=V(v);
         w = 1;K1=0;
         K2 = K1+2*w; x = 2*(sin(Kx)+sin(Ky));
         r1 = 8; r2 = 0.001*r1; T = 3*sin(Kz);
         A=[  -r1   r2-r1  -i*x      i*x      0           0       0              0;
               0    -r2       0       0       0           0      i*T           -i*T;
            -2*i*x  -i*x -r1-i*K1*0.5 0     -i*T          0       0              0;
             2*i*x  i*x       0  -r1+i*K1*0.5 0          i*T      0              0;
               0     0      -i*T      0 -r2-i*(K1+K2)*0.5 0      i*x             0;
               0     0        0      i*T      0 -r2+i*(K1+K2)*0.5 0             -i*x;
              i*T 2*i*T       0       0      i*x          0 -r2-r1+i*(K1-K2)*0.5 0;
             -i*T -2*i*T      0       0       0         -i*x      0 -r2-r1-i*(K1-K2)*0.5];
         B = [-r1;0;-i*x;i*x;0;0;i*T;-i*T];
         Y = A\B;
     P(n, m, v) = imag(Y(3)); % <---------------------------P向量中的元素赋值
           end
     end
end
[X,Y,Z]=meshgrid(W,K,V);
figure;slice(X,Y,Z,P,[-2.5 0 2.5],0,[-2 2])
result = HistRate(P(:));
[Pm,I]=max(result(:,2));
figure;
result(I,1)
Pv=isosurface(X,Y,Z,P,result(I,1));
p=patch(Pv)

用matlab 画三维图,请高手指教.-1
untitled1.jpg

The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
13楼2015-01-04 15:36:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
wzp0098: 金币+60, ★★★很有帮助, 多谢了 2015-01-04 22:14:08
引用回帖:
13楼: Originally posted by dbb627 at 2015-01-04 15:36:05
function slice_4D
W=-3:0.05:3;K=-3:0.05:3;V=-3:0.05:3;
P = [];
for n=1:length(W);
          Ky=W(n);
      for m=1:length(K);
          Kx=K(m);
           for v=1:length(V);
              ...

HistRate可换成tabulate 函数主要找出P中出现最多的那个值,
Pv=isosurface(X,Y,Z,P,result(I,1)); result(I,1)可换成其他可以取到的P值
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
14楼2015-01-04 15:42:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
15楼: Originally posted by wzp0098 at 2015-01-04 16:46:47
问一下,这P(n, m, v)的四维图吗...

Pv=isosurface(X,Y,Z,P,result(I,1));是画的三维等值面啊
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
16楼2015-01-04 16:50:40
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
17楼: Originally posted by wzp0098 at 2015-01-04 16:59:07
也就P(n, m, v)有关于X,Y,Z的图形?...

这P(n, m, v)的四维图是第一个帖子里面画的图,后面这个是等值面
他们的关系就像三维曲面和等值线之间的关系

» 本帖已获得的红花(最新10朵)

The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
18楼2015-01-04 18:29:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 wzp0098 的主题更新
信息提示
请填处理意见