MATLAB関数を実行しようとすると、警告メッセージが表示されます。エラーは、MATLAB関数を実行しようとすると、警告メッセージが表示されます。「
です"警告:t = 3.107182e-03でのエラー。 のステップサイズを時刻tで許容される最小値(6.938894e-18)以下に下げることなく、積分公差を満たすことができません。 ode15sは(ライン730)」
では、私は関数の中で特異点を見つけなければならないけど、私は前にエラーにコンパイルすることができました頌歌値を表示するために自分自身を有効にする方法を確認していない。 誰もが値を表示する方法を知っている私のコードは次のようである:?
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
あなたのコードを投稿してください。 – Eppicurt
ただで掲示される 質問! – Laura
'options'入力で[ode15s'](https://uk.mathworks.com/help/matlab/ref/ode15s.html#inputarg_options)のドキュメントを見てください。ソルバが進むにつれて、より緩やかな公差を設定したり、ソリューションを出力したりすることができます。 – Wolfie