prompt for variables in an equation
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I am new here and to Matlab so here is my question. How do I promp a user for variables in an equation and after the answer is given to loop back again in order to enter new variable?
example:
promp for r
promp for h
r^2*acos((r-h)/r)-(r-h) * sqrt(2*r*h-h^2)
answer =
Loop
0 个评论
采纳的回答
Walter Roberson
2012-2-26
while true
r = input('How about sending an r value over this way?');
h = input('Groovy. Got a spare h value too?');
r^2*acos((r-h)/r)-(r-h) * sqrt(2*r*h-h^2)
end
3 个评论
Walter Roberson
2019-5-23
while true
r = input('How about sending an r value over this way?');
if isscalar(r) && isnumeric(r); break; end
end
while true
h = input('Groovy. Got a spare h value too?');
if isscalar(h) && isnumeric(h); break; end
end
disp( r^2*acos((r-h)/r)-(r-h) * sqrt(2*r*h-h^2) )
更多回答(1 个)
Panagiotis Panos Katranitsas
2012-2-25
Hi Ken,
i think the instruction input is what you need.
ex.
reply = input('Do you want more? Y/N [Y]: ', 's');
if isempty(reply)
reply = 'Y';
end
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!