Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

i encountered an error saying Undefined function 'Linda' for input arguments of type 'char', while trying save a file and run a code

1 Ansicht (letzte 30 Tage)
Function Y = linda_77
N=100; % Total population size
en=50; % plot every enth time interval
T=zeros(N+1,N+1); % T is the transition matrix, defined below
v=linspace(0,N,N+1);
p=zeros(time+1,N+1);
p(1,3)=1; % Two individuals initially infected.
bt=beta*v.*(N-v)/N;
dt=(b+gama)*v;
for i=2:N % Define the transition matrix
T(i,i)=1-bt(i)-dt(i); % diagonal entries
T(i,i+1)=dt(i+1); % superdiagonal entries
T(i+1,i)=bt(i); % subdiagonal entries
end
T(1,1)=1;
T(1,2)=dt(2);
T(N+1,N+1)=1-dt(N+1);
for t=1:time
y=T*p(t,:);
p(t+1,:)=y;
end
pm(1,:)=p(1,:);
for t=1:time/en;
pm(t+1,:)=p(en*t,:);
end
ti=linspace(0,time,time/en+1);
st=linspace(0,N,N+1);
mesh(st,ti,pm);
xlabel(Number of Infectives);
ylabel(Time Steps);
zlabel(Probability);
view(140,30);
axis([0,N,0,time,0,1]);

Antworten (1)

Walter Roberson
Walter Roberson am 16 Jun. 2019
MATLAB is case sensitive. That code would not be recognized as a function because you used Function instead of function
With that change made, this code would define a function named linda_77 . With the _77 that cannot match Linda even if you fixed the case sensitivity problem.
If you want this function to be invoked as Linda then you should change it to function Linda and store it in Linda.m

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by