Calculator with arithmetic sequences as input values

Hello,
I'm writing because I can not figure out how to solve the problem.
I have created a calculator to calculate the force at a certain depth, now I'm trying to make make it show different values at different depths.
The values for imput are Minimum depth of a hole, maximum depth and the common difference alongside other constants.
I want it to calculate the force for every value and show values of all the forces.
Example: Minimum depth=1mm ; Maximum depth=5mm; Common difference=1mm.
F=H*a*b; where H is the depth, F is the force and a and b are the constants.
Force (at 1mm)= 100N ; Force (at 2mm) = 200N ; Force (at 3mm) = 300N ...
I have tried it with the for loop, but I had no luck.
I would be very grateful for any help.

3 件のコメント

Geoff Hayes
Geoff Hayes 2019 年 5 月 31 日
Aleksej - since a and b are constants, does that mean that H is the only variable that will change value on each iteration of your loop? Is H the minimum depth, the maximum depth, or the commond difference?
Aleksej R
Aleksej R 2019 年 5 月 31 日
Hello,
In the first version of the calculator I only had the H which was THE depth. This was the only variable.
So the input values were for example: Depth (H), speed (constant),.... With this version I could only get one result (one force value).
But in the second version I have to make Hmin, Hmax and the common difference.
So it will be: Minimum depth (Hmin), Maximum depth (Hmax) and the common difference (let's say its symbol is D).
Geoff Hayes
Geoff Hayes 2019 年 5 月 31 日
ok...so perhaps the following will help (I'm guessing as to your intentions of the minimum, maximum, and commond difference)
a = 42; % dummy value
b = 2; % dummy value
minDepth = 1;
maxDepth = 5;
commonDiff = 1; % your step size (?)
F = zeros(5,1);
k = 1;
for h = minDepth:commonDiff:maxDepth
F(k) = h*a*b;
k = k + 1;
end

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2018a

質問済み:

2019 年 5 月 31 日

コメント済み:

2019 年 5 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by