Need help with creating a function of three parameters

1 回表示 (過去 30 日間)
Stirling Ellis
Stirling Ellis 2022 年 5 月 2 日
コメント済み: Jon 2022 年 5 月 2 日
Need help creating a function of three parameters. Below I have my code, but it returns no values. The code should take in the parameters H, VR, and TR. Here is the snip below:
l = 300; %m
wo = 1e5; %Nm
f = 20; %
H = wo * l.^2 ./ (8*f); %Horizontal reaction force
VR = wo .* l / 2; %Vertical reaction force
TR = VR * sqrt(1+ l.^2 ./ (16 * f.^2)); %Tension in cable
L = 1/2 * sqrt(1+ (wo .* l / (2*H)) .^2 ) + H/wo * sinh(wo * l/ (2*H));
%MATLAB function to take in three parameters
function [output] = Force(l,wo,f)
end
Thank you in advance!
  2 件のコメント
Torsten
Torsten 2022 年 5 月 2 日
The problem is part of the answer. So it doesn't help to delete it here.
Stirling Ellis
Stirling Ellis 2022 年 5 月 2 日
Didn't think it through. Went ahead and re uploaded it. Thank you

サインインしてコメントする。

採用された回答

Jon
Jon 2022 年 5 月 2 日
編集済み: Jon 2022 年 5 月 2 日
You're close. Just put the formulaes inside of the function, and return the outputs of interest. Something like the code shown below. (It looks like you also wanted to compute L, the tension in the cable so I included that in the function. You could also just have returen H, VR,and TR in the function and then computed L.)
Also, to keep everything just in the one screen in the post I put the function at the bottom of a script. You could also save it as a separate .m file
% Inputs:
% l = bridge length (m)
% wo = load per unit length (N/m) % f = cable sag distance (m)
% Outputs:
% H = horizontal force at cable support point (N)
% VR = vertical reaction force at cable support point (N) % TR = cable tension force at support point (N)
l = 400; %m
wo = 1.5e5; %Nm
f = 20; %m
% call the function
[H,VR,TR,L] = Force(l,wo,f)
%MATLAB function to take in three parameters
function [H,VR,TR,L] = Force(l,wo,f)
% Formulas
H = wo * l.^2 ./ (8*f);
VR = wo .* l / 2;
TR = VR * sqrt(1+ l.^2 ./ (16 * f.^2));
% tension in cable
L = 1/2 * sqrt(1+ (wo .* l / (2*H)) .^2 ) + H/wo * sinh(wo * l/ (2*H));
end
  2 件のコメント
Stirling Ellis
Stirling Ellis 2022 年 5 月 2 日
Thank you so much!
Jon
Jon 2022 年 5 月 2 日
Your welcome. Good luck with your project

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by