The matlab code does not display the graph with Matlab R2015a
2 ビュー (過去 30 日間)
古いコメントを表示
Mathew Aibinu
2023 年 2 月 22 日
コメント済み: Oguz Kaan Hancioglu
2023 年 2 月 23 日
clear all; close all;
syms k t
I_0=1; mu=1.5; lambda=0.3; gamma=0.1;
t=0:1:20;
y=I_0*symsum((-lambda *t.^(mu)).^k/(2.^((k*(k-1)*mu)/2)*factorial(k* mu)),k,[0, Inf]) + gamma*symsum(((-lambda).^(k-1)*(t.^(k*mu)))/(2.^((k*(k-1)*mu)/2)*factorial(k* mu)),k,[1 Inf]);
plot(t,y,'-+');
grid on
xlabel('time t');
ylabel('I(t)');
The graph is not displayed with Matlab R2015a
0 件のコメント
採用された回答
Walter Roberson
2023 年 2 月 23 日
If I recall correctly, back in R2015a, fplot did not yet apply to symbolic expressions.
That symsum() to infinity does not find a closed form solution so it leaves it as a symsum. If you use matlabFunction() on the result, then it leaves it in terms of symsum(), which is not a good thing as symsum is not defined for numeric parameters. You can attempt to fplot() the resulting handle, but it takes too long for any practical purposes. If you substitute in specific t values and run the symsum with those, it takes too long for any practical purposes.
I think for practical purposes you are going to need to truncate the infinite sums.
You also have the problem that you have factorial(k*mu) but mu = 1.5 so for odd integers k*mu is non-integral which is a problem for factorial. You have to switch to gamma.
TERMS = 30;
syms k t
I_0=1; mu=1.5; lambda=0.3; Gamma=0.1;
t=0:1:20;
inner1 = (-lambda *t.^(mu)).^k./(2.^((k*(k-1)*mu)/2).*gamma(k*mu+1));
inner2 = ((-lambda).^(k-1).*(t.^(k*mu)))./(2.^((k*(k-1)*mu)/2).*gamma(k*mu+1));
inner1sum = symsum(inner1, k, [0, TERMS]);
inner2sum = symsum(inner2, k, [1, TERMS]); %notice different bounds
y = I_0 * inner1sum + Gamma * inner2sum;
Y = double(y);
plot(t, Y)
grid on
xlabel('time t');
ylabel('I(t)');
0 件のコメント
その他の回答 (1 件)
Oguz Kaan Hancioglu
2023 年 2 月 22 日
Keep your t variable in symbolic and use fplot to plot the symbolic function.
Bests
clear all; close all;
syms k t
I_0=1; mu=1.5; lambda=0.3; gamma=0.1;
%t=0:1:20;
y=I_0*symsum((-lambda *t.^(mu)).^k/(2.^((k*(k-1)*mu)/2)*factorial(k* mu)),k,[0, Inf]) + gamma*symsum(((-lambda).^(k-1)*(t.^(k*mu)))/(2.^((k*(k-1)*mu)/2)*factorial(k* mu)),k,[1 Inf]);
fplot(y,[0,20]);
grid on
xlabel('time t');
ylabel('I(t)');
2 件のコメント
Oguz Kaan Hancioglu
2023 年 2 月 23 日
Try to use ezplot for older versions.
fplot is newer version of ezplot.
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!