How to call the second function inside the first function under the same file
古いコメントを表示
% That is my code
% the expected result is :
Please enter the first user name: abby
Please enter the first user name: bob
The first user abby have 15 points
The second user bob have 15 points
% but there are bug on my code
function [p1,p2,Name1,Name2]= Playerpoint(point1,point2)
point1 = 10;
point2 = 11;
p1 = card1 + 5;
p2= card2 + 4;
Name1 = name1;
Name2 = name2;
fprintf("The first user %s has %d points\n",Name1,c1);
fprintf("The second user has %d points\n",Name2,c2);
end
function [name1,name2] = Playername(n1,n2)
name1 = n1;
name2 = n2;
end
% driver files
n1 = input('Please enter the first user name: ','s');
n2 = input('Please enter the second user name: ','s');
[name1,name2] = Playername(n1,n2);
card1 = 0;
card2 = 0;
[p1,p2,Name1,Name2]= Playerpoint(point1,pointt2);
% How to improve my code
% Thank you
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Instrument Control Toolbox Supported Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!