The matlab code does not display the graph with Matlab R2015a
2 次查看(过去 30 天)
显示 更早的评论
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!