簡體   English   中英

嘗試運行MATLAB函數時,我收到警告,感到很掙扎。出現的錯誤是“

[英]Struggling with a warning I am receiving when trying to run my MATLAB function.. The error that comes up is "

嘗試運行我的MATLAB函數時,我收到警告,感到很掙扎。出現的錯誤是

“警告:在t = 3.107182e-03時失敗。在不將步長減小到低於時間t允許的最小值(6.938894e-18)的情況下,無法滿足積分公差。在ode15s中(線730)”

我知道我必須在函數中找到奇點,但是我不確定如何使自己能夠查看能夠在錯誤之前進行編譯的ode值。 有人知道如何查看值嗎? 我的代碼如下:

function EMatlabModel()
 % Define constants
 H = 0.04; %[m] Height between cathode and anode
 D = 0.000399; %[m^2/s] diffusion
 F = 96485.3329; %[C] Faraday's constant
 z = 1; % charge of gold
 r = 0.02; %[m] radius of space between electrodes
 m = 1; % mobility of gold
 R = 0.008314; %[J/molK] - divded by 1000 to ensure correct units
 T = 360.65; %[K] temperature of cell
 nY = 99; % Number of interior nodes (y direction)
 dY = (H - 0)/(nY + 1); % Node spacing (y direction)
 tspan = [0 H];
 Co = 0.01*ones(nY+1,1);

% Integrate discretized ODEs using ode15s
sol = ode15s(@funcs,tspan,Co)

% Plot the results
x = linspace(0.15,0.95,5);
el = deval(x,sol)
plot(x,el)
colormap hsv
colorbar
xlabel('Length Away from Cathode');
ylabel('Concentration of Gold');

 %------------------------------------------------------------
 % Define functions to be integrated in x.
 %------------------------------------------------------------
function res = funcs(x,y) % where y = C
    res=zeros(nY+1,1);

    %u = 1e-10;
    um = 0.04;
    Cin = 0.01;
    Vin = 5 + 2.037;

     res(1) = D/dY^2*(y(2) - 2*y(1) + Cin)+ ...
         D/z/dY^2*(y(2) - 2*y(1) + Cin) + ...
         y(1)*um*2*(abs(y(1) - r/2)/r^2) + D*y(1)*F*z*m*Vin/(R*T*H);

      for j = 2:nY
         %ux(j) = um*(1 - abs(y(j) - r/2)/r);
         res(j) = D/dY^2*(y(j+1) - 2*y(j) + y(j-1)) +... 
             + D/z/dY^2*(y(j+1) - 2*y(j) + y(j-1)) + ...
             y(j)*um*2*(abs(y(j) - r/2)/r^2) + D*y(j)*F*z*m*Vin/(R*T*H);
      end
  end
 end

我無法發表評論,但是為了使您的解決方案明顯有所不同,這就是為什么您會收到該錯誤,您需要嘗試使用tspan並進一步限制它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM