# How can I plot integral of this equation?

2 ビュー (過去 30 日間)
E kara 2021 年 7 月 29 日
コメント済み: Star Strider 2021 年 7 月 29 日
I couldn't manage to plot this equation over time.
I wrote the formula for integral, but these are scalar, but i had to wrote '.*' instead of *
I should have a decreasing trend, but there is no plot. Iam new in Matlab, could you please let me know where is the my mistakes?
clc;
figure('color','white');
while(1)
sigma.phi=input('Enter 0.1 in a.u.: ');
mu=input('Enter 2 in mm-1: ');
n=input('number of evicted electrons: ');
for t=0:300
fun=@(x)(n).*(exp(-((mu).*x))).*(exp(-((sigma.phi).*t.*(exp(-(mu).*x)))));
Q=integral(fun,0,1);
end
plot(Q,[0,300]);
xlabel('Time / s ');
title('Signal');
ylabel('Intensity');
hold all;
ch= input('Press 1 to continue and 0 to exit: ')
if ch == 0
break;
end
end

サインインしてコメントする。

### 採用された回答

Star Strider 2021 年 7 月 29 日
Try something like this —
% clc;
figure('color','white');
while(1)
sigma.phi=input('Enter 0.1 in a.u.: ');
mu=input('Enter 2 in mm-1: ');
n=input('number of evicted electrons: ');
t=0:300;
fun=@(x,t)(n).*(exp(-((mu).*x))).*(exp(-((sigma.phi).*t.*(exp(-(mu).*x)))));
for k = 1:numel(t)
Q(k)=integral(@(x)fun(x,t(k)),0,1);
end
plot(t,Q);
xlabel('Time / s ');
title('Signal');
ylabel('Intensity');
hold all;
ch= input('Press 1 to continue and 0 to exit: ')
if ch == 0
break;
end
end
.
##### 2 件のコメント表示非表示 1 件の古いコメント
Star Strider 2021 年 7 月 29 日
As always, my pleasure!
.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!