sum=0;
Do NOT use sum as a variable name: this shadows the inbuilt, very important sum function, and is likely to break a lots of code.
sum=0;
Do NOT use sum as a variable name: this shadows the inbuilt, very important sum function, and is likely to break a lots of code.
"if anyone could point me in the right direction that would be appreciated"
Your assignment points you in the right direction. Start by reading it again:
"Use while-end, if-end, break commands to solve the numerical problem..."
So you need to generate random numbers inside a while loop until some condition is met, testing another condition using if and leaving the loop using break... this is pretty easy to transfer into code:
tot = 0; % Do NOT use SUM as a name.
while ???
num = randn(???)
if ???
???
break
end
tot = ???
end
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!