我是靠谱客的博主 坦率橘子,最近开发中收集的这篇文章主要介绍[MATLAB调试笔记]Update magnetic field in one step,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

function [field] = bfield(field,prm)
    % Update magnetic field in one step
    X2 = prm.X2;
    f = field; % reference to Field obj

    f.by(X2) = f.by(X2) + f.ez(  X2) - f.ez(X2-1);
    f.bz(X2) = f.bz(X2) - f.ey(X2+1) + f.ey(X2  );

    f.by(prm.nxp2)= f.by(2);%对称边界条件
    f.bz(prm.nxp2)= f.bz(2);
    f.by(1)   = f.by(prm.nxp1);
    f.bz(1)   = f.bz(prm.nxp1);
end

>> prm.X2

ans =

  Columns 1 through 16

     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17

  Columns 17 through 32

    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33

  Columns 33 through 48

    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49

  Columns 49 through 64

    50    51    52    53    54    55    56    57    58    59    60    61    62    63    64    65

  Columns 65 through 80

    66    67    68    69    70    71    72    73    74    75    76    77    78    79    80    81

  Columns 81 through 96

    82    83    84    85    86    87    88    89    90    91    92    93    94    95    96    97

  Columns 97 through 112

    98    99   100   101   102   103   104   105   106   107   108   109   110   111   112   113

  Columns 113 through 128

   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129

>> f.by(X2)

ans =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0

>>  f.ez(  X2)

ans =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0

>> f.by(X2) = f.by(X2) + f.ez(  X2) - f.ez(X2-1)

f = 

  Field with properties:

     ex: [130×1 double]
     ey: [130×1 double]
     ez: [130×1 double]
     by: [130×1 double]
     bz: [130×1 double]
    rho: [130×1 double]
    ajx: [130×1 double]
    ajy: [130×1 double]
    ajz: [130×1 double]

>> f.by(X2) = f.by(X2) + f.ez(  X2) - f.ez(X2-1)

f = 

  Field with properties:

     ex: [130×1 double]
     ey: [130×1 double]
     ez: [130×1 double]
     by: [130×1 double]
     bz: [130×1 double]
    rho: [130×1 double]
    ajx: [130×1 double]
    ajy: [130×1 double]
    ajz: [130×1 double]

>> f.bz(X2) = f.bz(X2) - f.ey(X2+1) + f.ey(X2  )

f = 

  Field with properties:

     ex: [130×1 double]
     ey: [130×1 double]
     ez: [130×1 double]
     by: [130×1 double]
     bz: [130×1 double]
    rho: [130×1 double]
    ajx: [130×1 double]
    ajy: [130×1 double]
    ajz: [130×1 double]

>> bfield(field,prm)
Unrecognized function or variable 'bfield'.
 
Did you mean:
>> field(field,prm)
Unable to use a value of type Field as an index.
 
>> bfield(field,prm)

ans = 

  Field with properties:

     ex: [130×1 double]
     ey: [130×1 double]
     ez: [130×1 double]
     by: [130×1 double]
     bz: [130×1 double]
    rho: [130×1 double]
    ajx: [130×1 double]
    ajy: [130×1 double]
    ajz: [130×1 double]

>> 

最后

以上就是坦率橘子为你收集整理的[MATLAB调试笔记]Update magnetic field in one step的全部内容,希望文章能够帮你解决[MATLAB调试笔记]Update magnetic field in one step所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部