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

1 view (last 30 days)
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 Comments
Adam
Adam on 27 Jul 2018
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 on 27 Jul 2018
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.

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!