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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Adam
Adam am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ben Frankel
Ben Frankel am 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);

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by