How to fix "Out of memory. The likely cause is an infinite recursion within the program. Error in integralCalc/iterateScalarValued (line 312) [t,w] = u(x); % Transform back to the original domain."
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to run this fourier series but I am not sure why I am receiving this error
function result = dracu(t,T)
f0=50;
omega0=2*pi*f0;
T=1/f0;
step=T/100;
t=-T:step:2*T;
result = zeros(1,length(t));
for index_t = 1:length(t)
if mod(t(index_t),T)<T/2
result(index_t) = 1;
else
result(index_t) = -1;
end
end
a0over2 = 1/T * integral(@(t)dracu(t,T),0,T);
N=10;
a=zeros(1,N);
b=zeros(1,N);
for k=1:N
a(k) = 2/T * integral(@(t)(dracu(t,T).*cos(k*omega0*t)),0,T);
b(k) = 2/T * integral(@(t)(dracu(t,T).*sin(k*omega0*t)),0,T);
end
a;
b;
end
0 件のコメント
回答 (2 件)
Walter Roberson
2018 年 10 月 23 日
function result = dracu(t,T)
so you are within function dracu
a0over2 = 1/T * integral(@(t)dracu(t,T),0,T);
and in that function dracu, you ask to integrate the results of invoking dracu
for k=1:N
a(k) = 2/T * integral(@(t)(dracu(t,T).*cos(k*omega0*t)),0,T);
b(k) = 2/T * integral(@(t)(dracu(t,T).*sin(k*omega0*t)),0,T);
end
and more places that you are asking dracu to integrate the result of running itself.
You have not programmed in any termination, so you have infinite recursion.
Perhaps the lines starting from a0over2 = 1/T * integral(@(t)dracu(t,T),0,T); should be within a different file.
0 件のコメント
abdul rehman
2021 年 12 月 22 日
編集済み: Walter Roberson
2021 年 12 月 22 日
% Bus Admittance Matrix
% Copyright (c) 1998 by H. Saadat.
function[Ybus] = ybus(zdata)
nl=zdata(:,1); nr=zdata(:,2); R=zdata(:,3); X=zdata(:,4);
nbr=length(zdata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; %branch impedance
y= ones(nbr,1)./Z; %branch admittance
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
for k = 1:nbr; % formation of the off diagonal elements
if nl(k) > 0 & nr(k) > 0
Ybus(nl(k),nr(k)) = Ybus(nl(k),nr(k)) - y(k);
Ybus(nr(k),nl(k)) = Ybus(nl(k),nr(k));
end
end
for n = 1:nbus % formation of the diagonal elements
for k = 1:nbr
if nl(k) == n | nr(k) == n
Ybus(n,n) = Ybus(n,n) + y(k);
else, end
end
end
Out of memory. The likely cause is an infinite recursion within the program. i am facing this error
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!