필터 지우기
필터 지우기

Trying to plot radioactive decay equation

조회 수: 5 (최근 30일)
Daniel Vinther
Daniel Vinther 2015년 6월 14일
답변: Narayan guragain 2021년 5월 17일
I am trying to plot a radioactive decay equation. I have attached a screen shot of my current code and a picture of the final result that I need to go get to. Why is my current code not working? Matlab won't plot it.

채택된 답변

Mischa Kim
Mischa Kim 2015년 6월 14일
편집: Mischa Kim 2015년 6월 14일
Daniel, you can simply do
lambda = log10(2)/5700;
x = 1:100;
y = (-1/lambda)*log10(x/100);
plot(x,y)

추가 답변 (2개)

Ayesha Altaf
Ayesha Altaf 2021년 1월 10일
function matlab
clc;clear;
%Radioactive decay
y0=[5*10^26;0];
soln = ode23(@f1,[0 8],y0)
t = linspace(0,8,24);
y(:,1)=deval(soln,t,1); %Strontium
y(:,2)=deval(soln,t,2); % Yttrium
figure
plot(t,y(:,1),'-o',t,y(:,2),'--');
hold on;grid on;
legend('Strontium','Yttrium')
end
function dxdt = f1(x,t)
r1 = 0.256;
r2 = 0.127;
dxdt(1) = -r1 * x;
dxdt(2) = -r2 * x;
dxdt =dxdt';
end
function matlab
Error: Function definition not supported in this context. Create functions in code file.
what's wrong with this code. why it show error can anyone tell?

Narayan guragain
Narayan guragain 2021년 5월 17일
clear all
clc
%%Radioactive Decay%%
N0=5*10^22;
lemda=0.25;
t=[0:10];
N=N0*exp(-lemda.*t);
plot(t,N,"r");
xlabel("Half Life");
ylabel("Particles Undecayed");
title("Radioactive Decay");

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by