function[BeamWeightN,BeamWeightN_X,FB_X,FB_Y,FA_Y,ErrStatus]=BeamReactions(BeamLength,BeamMass,Load,LoadX,LoadAngle)
%fprintf("check to make sure that BeamLength is in meters,BeamMass is in Kg/m, Load is in Newotns,LOadX is in meters, LoadAngle is in degrees CCW")
%BeamLength = 16; % meters
%BeamMass = 45; % Kg/m
%Load = 4800; % Newton
%LoadX = 3; % Location of Load in meters from Roller Support
%LoadAngle = 135; % CCW angle in Degrees
a=isnumeric(BeamLength);
b=isnumeric(BeamMass);
c=isnumeric(Load);
d=isnumeric(LoadX);
e=isnumeric(LoadAngle);
if a==1 && b==1 && c==1 && d==1 && e==1
BeamWeightN=BeamMass*BeamLength*9.81
BeamWeightN_X=BeamLength/2
FB_X=Load*(cosd(LoadAngle))
FB_Y=(LoadX*(Load*(sind(LoadAngle)))+(BeamLength/2)*BeamWeightN)/BeamLength
FA_Y=(Load*(sind(LoadAngle)))+BeamWeightN-FB_Y
else
ErrStatus=1;
fprintf("you have inputed a nonscalar value");
end
end
it keeps returning "ans= 7.0632e+03"
thank you

 채택된 답변

Star Strider
Star Strider 2018년 3월 26일

0 개 추천

If you call it as:
Y = BeamReactions(BeamLength,BeamMass,Load,LoadX,LoadAngle)
it will only return the first output.
If you call it as:
[BeamWeightN,BeamWeightN_X,FB_X,FB_Y,FA_Y,ErrStatus] =BeamReactions(BeamLength,BeamMass,Load,LoadX,LoadAngle)
it will return all of them.

댓글 수: 1

is there anywhay to force it to input all outputs without calling them? just with the function's name
One option would be to put all of them in a cell array or structure, then return that one result as the output (given the default variable name ‘ans’).
The cell array approach would go something like this —
x = pi/3;
fcn(x)
ans = 3×1 cell array
{[0.8660]} {[0.5000]} {[1.7321]}
function out = fcn(x)
out{1,:} = sin(x);
out{2,:} = cos(x);
out{3,:} = tan(x);
end
,

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stephen23
Stephen23 2018년 3월 26일

1 개 추천

Make sure that you call it with the correct number of output arguments, e.g.:
[BeamWeightN,BeamWeightN_X,FB_X,FB_Y,FA_Y,ErrStatus] = BeamReactions(...)

댓글 수: 1

is there anywhay to force it to input all outputs without calling them? just with the function's name

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2018년 3월 26일

댓글:

2021년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by