sym/subs errors

3 次查看(过去 30 天)
Daniel
Daniel 2020-12-3
回答: Aniket 2025-1-27
v=[];
global a
global N
global k
fplot=fopen('saida_plot','w+');
r=find(diff(subs(diff(1/(((1-a)*(log(N)/log(k)+1))+(a)*(k)),k), {N,k,a},{600,1:1:100,0.1})>=0));
for alpha=0.1:0.1:1
r=find(diff(subs(diff(1/(((1-a)*(log(N)/log(k)+1))+(a)*(k)),k), {N,k,a},{600,1:1:100,alpha})>=0));
if (isempty(r))
alpha;
v=[v,1];
fprintf(fplot,'%d',[v,1])
else
v=[v,max(r)];
fprintf(fplot,'%d',[v,max(r)])
end
end
  1 个评论
Daniel
Daniel 2020-12-3
Running the code above I got several errors:
Error using symengine
Division by zero.
Error in sym/subs>mupadsubs (line 160)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 145)
G = mupadsubs(F,X,Y);
Error in Novo (line 7)
r=find(diff(subs(diff(1/(((1-a)*(log(N)/log(k)+1))+(a)*(k)),k), {N,k,a},{600,1:1:100,0.1})>=0));
Error using symengine
Division by zero.
Error in sym/subs>mupadsubs (line 160)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 145)
G = mupadsubs(F,X,Y);
Error in Novo (line 7)
r=find(diff(subs(diff(1/(((1-a)*(log(N)/log(k)+1))+(a)*(k)),k), {N,k,a},{600,1:1:100,0.1})>=0));
As it a legacy code and newbie in matlab, would please support me ?

请先登录,再进行评论。

回答(1 个)

Aniket
Aniket 2025-1-27
As mentioned in error output, the issue is because of "Division by zero". The expression logN/logK will cause a division by zero error if 'k' is 1, because log(1) is 0.
To ensure 'k' never takes a value of 1, range of 'k' can be changed from 1:1:100 to 2:1:100.
I hope this helps resolve the issue!

标签

Community Treasure Hunt

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

Start Hunting!

Translated by