sym/subs errors

4 Ansichten (letzte 30 Tage)
Daniel
Daniel am 3 Dez. 2020
Beantwortet: Aniket am 27 Jan. 2025
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 Kommentar
Daniel
Daniel am 3 Dez. 2020
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 ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Aniket
Aniket am 27 Jan. 2025
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!

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by