How can i solve an equation with vector(s) and if this can be done using conditional statement
Afficher commentaires plus anciens
I'm trying to solve an equation to find variable Sw and there are variables that are vectors but i don't know how to solve it all at once without having to define each value in the vector separately.
I also wonder if the equation can be solved using conditional statement. Below is the code including the vector Rw and Sw. Thank you
function Sw= Sw(n,m,p,Qv,B,Rw,Rt,SW)
n=2.2;
m=1.86;
p=0.153;
Qv=0.980;
B=3.200;
Rw=0.265;
Rt=[4.05; 4.10; 4.22; 4.30; 4.38; 4.54; 4.82; 5.03; 5.23; 5.43; 5.64; 5.80;6.24; 6.49; 6.61;6.73; 6.73; 6.69; 7.01; 7.50; 7.78; 8.15; 8.27; 8.47; 9.24; 9.97; 10.58;10.95; 11.39; 11.64; 12.00; 12.41; 13.46; 13.91; 15.20; 19.28; 21.08;22.83;24.77; 26.23; 28.06; 30.17;31.02; 31.50];
SW=[1.000; 0.998; 0.962; 0.938; 0.913; 0.895; 0.883; 0.871; 0.859; 0.840; 0.822; 0.816; 0.775; 0.763; 0.751; 0.745; 0.739; 0.721; 0.702; 0.684; 0.666; 0.654; 0.642; 0.611; 0.590; 0.563; 0.557; 0.549; 0.531; 0.519; 0.500; 0.488; 0.476; 0.458; 0.391; 0.361; 0.342; 0.324; 0.318; 0.306; 0.294; 0.288; 0.285; 0.276];
Sw=sqrt(n)(Rw/((p^m)*Rt*(1+(Qv*B*Rw)/Sw)));
end
2 commentaires
Kevin Joshi
le 3 Juin 2020
There is already a eq for Sw... Please explain the use of conditional statement.
KSSV
le 3 Juin 2020
Don't name the function and output variable same.
Réponse acceptée
Plus de réponses (1)
David Hill
le 3 Juin 2020
n=2.2;
m=1.86;
p=0.153;
Qv=0.980;
B=3.200;
Rw=0.265;
Rt=[4.05; 4.10; 4.22; 4.30; 4.38; 4.54; 4.82; 5.03; 5.23; 5.43; 5.64; 5.80;6.24; 6.49; 6.61;6.73; 6.73; 6.69; 7.01; 7.50; 7.78; 8.15; 8.27; 8.47; 9.24; 9.97; 10.58;10.95; 11.39; 11.64; 12.00; 12.41; 13.46; 13.91; 15.20; 19.28; 21.08;22.83;24.77; 26.23; 28.06; 30.17;31.02; 31.50];
SW=[1.000; 0.998; 0.962; 0.938; 0.913; 0.895; 0.883; 0.871; 0.859; 0.840; 0.822; 0.816; 0.775; 0.763; 0.751; 0.745; 0.739; 0.721; 0.702; 0.684; 0.666; 0.654; 0.642; 0.611; 0.590; 0.563; 0.557; 0.549; 0.531; 0.519; 0.500; 0.488; 0.476; 0.458; 0.391; 0.361; 0.342; 0.324; 0.318; 0.306; 0.294; 0.288; 0.285; 0.276];
Sw=executeSw(n,m,p,Qv,B,Rw,Rt,SW);
function Sw= executeSw(n,m,p,Qv,B,Rw,Rt,SW)
Sw=sqrt(n)*(Rw./((p^m)*Rt.*(1+(Qv*B*Rw)./SW)));
end
1 commentaire
Aires Bulik
le 3 Juin 2020
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!