Assigning variable for a certain output.
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
function toss = coinToss
coin = randi([0:1], [1,1]);
disp(coin)
end
I have this function that will dispay either one or zero when I run it.
For 1 I want the variable to be h and for 0 I want the variable to be t. How can I do this? I tried to do if and elseif statements inside the function already but it didnt work.
2 个评论
Geoff Hayes
2020-3-24
Lauren - do you mean that you want to return an 'h' or a 't' (head or tail) if the coin is a 0 or 1 respectively? Since this is homework, how did you write the if/else statement (you don't need an elseif)?
Lauren Fennelly
2020-3-24
回答(0 个)
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!