Selection of a variable from a resulting equation

2 views (last 30 days)
close all ; % i need to determine values of "ep" and "v" according to the value of fi
clc; % the "v" and "ep" variables need to be determined from the given table
format long
F= 161;
v1=0.27;
v2=0.27;
E1=210000;
E2=210000;
D1=40/2 ;
d=6/2 ;
r=6.16/2;
AB=(2*(1/d))+(1/D1)-(1/r);
k1=(1-v1^2)/E1;
k2=(1-v2^2)/E2;
E=(2*E1*E2)/(E1+E2);
fi=abs((1/D1)+(1/r))/AB % ---> result of the equation determines "ep" and "v" from the table
ep=5.22; %---> variable to be chosen from the table
v=0.352; %---> variable to be chosen from the table
a=1.4*ep*((F/(E*AB))^(1/3));
b=1.4*v*((F/(E*AB))^(1/3));
P=(3*F)/(2*pi*a*b)
% I want my code to be able to automaticly determine "ep" and "v" after i change my other variables, and move on with rest of the calculations,
% Please see the picture attached, Thank you in advance

Answers (2)

Vilém Frynta
Vilém Frynta on 5 Dec 2022
Hi, this could be done by using find() and indexing. If your table structure will always be the same (meaning that your first and fourth row will always be fi, and under that, there will be ep and v) you can use indexing to choose the variables.
Please let us know which variable type you are using. Are you loading your data as a cell / matrix / table / structure?

Erdem Turan
Erdem Turan on 7 Dec 2022
i just did it as the following:
if fi<=0
ep=1
v=1
elseif 0<fi<=0.4
ep=1
v=1
elseif 0.4<fi<=0.5
ep=1.35
v=0.769
elseif 0.5<fi<=0.6
ep=1.48
v=0.718
elseif 0.6<fi<=0.7
ep=1.66
v=0.664
elseif 0.7<fi<=0.75
ep=1.91
v=0.608
elseif 0.75<fi<=0.8
ep=2.07
v=0.577
elseif 0.8<fi<=0.85
ep=2.295
v=0.545
elseif 0.85<fi<=0.9
ep=2.57
v=0.509
elseif 0.9<fi<=0.925
ep=3.06
v=0.462
elseif 0.925<fi<=0.95
ep=3.5
v=0.432
elseif 0.95<fi<=0.975
ep=4.14
v=0.395
else
ep=5.22
v=0.352
end

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!