code will not run, but gives no error message
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Eleftherios
2022년 12월 7일
0 개 추천
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?
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!