Matlab spring equation question
10 次查看(过去 30 天)
显示 更早的评论
Can someone please help me with the following question?
The force required to compress a linear spring is given by the equation;
where F is the force in newtons, k is the spring constant in newtons per meter and x is displacement. Write a program which will determine the compression of each spring for a given set of forces F and corresponding spring constants k. Use function round() to round the n-th element in the answer vector only.
For example:
TestResult
F = [20 30 80];
k = [20 10 20];
n_th = 2;
Result =
3
2 个评论
回答(1 个)
maiaL
2020-10-27
编辑:maiaL
2020-10-27
The way I understand the problem, you need an array "x" as the result of this program, which will have the same size as the arrays F and k. For that, I would use an element-wise division here:
x = F./k;
For the rounding part, I believe you'd need to use the round() function with a 2nd argument, like so:
x = round(x,n_th);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assembly 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!