필터 지우기
필터 지우기

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

채택된 답변

Walter Roberson
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)');

추가 답변 (1개)

Oguz Kaan Hancioglu
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
Mathew Aibinu
Mathew Aibinu 2023년 2월 23일
The graph is still not displayed. Here is result when I ran the code:
Error using fcnchk (line 106)
If FUN is a MATLAB object, it must have an feval method.
Error in fplot (line 60)
fun = fcnchk(fun);
Error in AAM24 (line 6)
fplot(y,[0,20]);
Kindly note that AAM24 is the name with which the file is saved.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by