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

조회 수: 1 (최근 30일)
Aaron Wazir
Aaron Wazir 2018년 7월 27일
답변: Ben Frankel 2018년 7월 27일
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