code will not run, but gives no error message
Mostrar comentarios más antiguos
I have written the following code that involves multiple functions. S calls A and B. Evidently this is wrong because the code is not running. However, I do not know what the problem is because it detects nothing wrong and gives no error message. I know that I can just define one function to complete this task, but I would like to know the best way to call a function within another function in matlab.
Here is the code:
function S = entropy(r,n)
A = stirling1(r,n);
B = stirling2(n);
S = A-log(factorial(r))-B;
function A = stirling1(r,n)
A = (r+n-1)*log(r+n-1)-(r+n-1)+log(2*pi(r+n-1));
disp(S)
end
function B = stirling2(n)
B = (n-1)*log(n-1)-(n-1)+log(2*pi*(n-1));
disp(S)
end
fprintf('entropy =%9.6\n',entropy(50,250))
end
Respuesta aceptada
Más respuestas (1)
Eleftherios
el 7 de Dic. de 2022
0 votos
function dxdt = odefun (t,x)
dxdt = zeros(3,1);
dxdt(1)= -(8/3)*x(1)+x(2)*x(3);
dxdt(2)= -10*x(2)+10*x(3);
dxdt(3)= -x(3) -x(2)*x(1)+28*x(2);
end
'Matlab says the problem is at the (t) , what can i do?
Categorías
Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!