i have an error about the general solution. it says that it's not found in the code
1 回表示 (過去 30 日間)
古いコメントを表示
%A zircon sample contains 5000 atoms of the radioactive element 235U.
%Given that 235U has a half‐ life of 650 million years, how long would it take to decay to 120 atoms?
%Setup the variables A(t), k that will be used in the program. Find also the derivative of A(t) and set as dA
syms k t A(t) dA x
dA = diff(A,t)
%Initial Conditions
cond1= A(0)==5000
cond2= A(650)==2500
%Set the differential equation model as eqn1;
eqn1 = dA==k*A
A(t) = dsolve(eqn1)
%Find k1 and k2, by solving the initial value problem eqn1 using cond1 and cond2, respectively.
k1 = dsolve(eqn1,cond1)
k2 = dsolve(eqn1,cond2)
%Solve for k by equating k1 and k2 at t=0. Save results as k.
h1 = subs (k1,sym("t"),0)
h2 = subs (k2,sym("t"),0)
k = solve(h1==h2,k)
%Solve the eqn1 using the acquired value of k and using Initial value cond1.
A0 = 5000==(subs(subs(dsolve(eqn1),sym("k"),k),t,0))
Ao = double(lhs(A0))
%Solve the equation when A(t) = Acondition. Save Answer as tfinal (This is in Million Years)
tsoln = 125==subs((subs(dsolve(eqn1),sym("k"),k)),sym("C1"),Ao)
isolate(tsoln,t)
tfinal = solve(tsoln,t)
A(t) = symfun(lhs(subs(subs(dsolve(eqn1),sym("k"),k),sym("C1"),A0)),t)
Asoln = symfun(subs((A(t)),sym("t"),sym("x")),x)
%Express your answer in years
tM = double(tfinal*10^6);
% Plot the equation: Use the Title=Radioactive Decay, XValue=Period(Million of Years), YValue=Atoms of 235U
Title = "Radioactive Decay"
XValue = "Period(Million of Years)"
YValue = "Atoms of 235U"
hold on;
title(Title)
xlabel(XValue)
ylabel(YValue)
%Use the domain (0, tfinal+5) with 0.2 gaps from each point
x=0:0.2:tfinal+500;
y=Asoln(x);
plot(x,y)
hold off;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!