Coin Flip simulation errors
古いコメントを表示
Here's my function code
H=nest1;
T=nest1;
function [H,T]=nest1(n,k)
while n <= k
n=n+1;
R = randi([1,2]);
H=0;
T=0;
if ISEQUAL(R,1)
H=H+1
disp('H')
end
if ISEQUAL(R,2)
T=T+1
disp('T')
end
end
end
end
here's my main code:
clear all, close all, clc
prompt='How many times do you want to flip the coin?';
k=input(prompt)
[htotal, ttotal]=coinflip(k)
I keep receiving a Not enough input arguments error at my while loop. I'm trying to do a coin flip function by calling a function in my main. any tips? I really need the help.
1 件のコメント
Walter Roberson
2015 年 11 月 21 日
Does the code in http://uk.mathworks.com/matlabcentral/answers/256701-coin-flip-plotting-every-flip imply that you solved this Question ?
回答 (1 件)
Image Analyst
2015 年 11 月 21 日
In nest1.m, you cannot have these two lines before your function line:
H=nest1;
T=nest1;
Also, your main code calls coinflip(), the code for which you did not post. You posted only code for next1().
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!