Need help with creating a function of three parameters

1 visualización (últimos 30 días)
Stirling Ellis
Stirling Ellis el 2 de Mayo de 2022
Comentada: Jon el 2 de Mayo de 2022
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 comentarios
Torsten
Torsten el 2 de Mayo de 2022
The problem is part of the answer. So it doesn't help to delete it here.
Stirling Ellis
Stirling Ellis el 2 de Mayo de 2022
Didn't think it through. Went ahead and re uploaded it. Thank you

Iniciar sesión para comentar.

Respuesta aceptada

Jon
Jon el 2 de Mayo de 2022
Editada: Jon el 2 de Mayo de 2022
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 comentarios
Jon
Jon el 2 de Mayo de 2022
Your welcome. Good luck with your project

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by