Trying to use function ,didnt work?
1 次查看(过去 30 天)
显示 更早的评论
function [Delta]= finddeflexion(Length)
E= 4.2*(10.^10);
I = 1*(10.^-5);
W = 8500;
prompt = "What is the length of the blade? ";
Length = input(prompt);
Delta = W*(Length^3)/(8*E*I);
when i typed it like this it gave me error sayin to type the function part like so and i dont understand why
function [Delta]= finddeflexion(~)
the code then works fine
2 个评论
采纳的回答
Matt J
2023-12-12
when i typed it like this it gave me error
I doubt it gave you an error. It certainly doesn't give me one.
You probably got a Code Analyzer warning saying that the input argument "Length" is not being used. If you want it to be used remove the line which overwrites it:
function [Delta]= finddeflexion(Length)
E= 4.2*(10.^10);
I = 1*(10.^-5);
W = 8500;
prompt = "What is the length of the blade? ";
%Length = input(prompt);
Delta = W*(Length^3)/(8*E*I);
end
10 个评论
Matt J
2023-12-12
编辑:Matt J
2023-12-12
instead of just pressing run and changing the value of length in command window
Yes, we removed the line where you are prompted for the Length from the command window.
If you want to set the Length variable in the command window, then you should put that line back in, but remove "Length" from the function signautre line
function [Delta]= finddeflexion() %or finddeflexion(~)
E= 4.2*(10.^10);
I = 1*(10.^-5);
W = 8500;
prompt = "What is the length of the blade? ";
Length = input(prompt); %<--- put this line back in
Delta = W*(Length^3)/(8*E*I);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!