Hey guys, I need help with this input dialogue to function use.

1 次查看(过去 30 天)
I'm a beginner so I need all the help I can get. I'm making a simple program to save time. It should give me minimum slab thickness, after giving the required input. It works as a simple function but I need it to work from the input dialogue. You can test it using these values. Clear span = 8 Thickness = 5 Strength = 40000
It should give an answer of 4.04 or 4.24 inch. Note: My code start from >>function EXP_Slab_Thick........
if true
% code
end
function EXP_Slab_Thick (~)
S = inputdlg({'Given clear span:' ,'Assumed thickness:' ,'Yield strength of steel:'},'required data', [1,45]);
a = str2double(S);
ln = S(1,1);
hfo = S(2,1);
fy = S(3,1);
l = ln + hfo/12;
if fy < 60000
h = (l/20)*(0.4+fy/100000)*12;
fprintf('The minimum height required is %.3f inch.\n Subtract o.75 from your new assumed height to get depth\n', h);
else
fprintf('Yield strength of steel is too high for this equation')
end
end
  2 个评论
Adam
Adam 2018-7-27
ln and fy are both referring to the same output from the inputdlg. Is this intended? I assume not though since their names bear no relation to the strings of the input dialog it is hard to tell what each should be!
Aaron Wazir
Aaron Wazir 2018-7-27
Sorry that was a mistake on my part. But the main problem is that the equation below needs a simple number. Double precision, I think? While the input gives in a cell. Dimensions problem.

请先登录,再进行评论。

采纳的回答

Ben Frankel
Ben Frankel 2018-7-27
You calculate a correctly, but you never use it. Try this:
a = str2double(S);
ln = a(1);
hfo = a(2);
fy = a(3);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by