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!