Question solve(eqn)

3 views (last 30 days)
Jothi
Jothi on 24 Feb 2025
Edited: Walter Roberson on 24 Feb 2025
Hello, I'm wondering, how can we take the values of the different variables which where found by the function 'solve' and use them for another calculation ? I wrote this and i need the values of a0, a1, a2, a3, a4 and a5 for the calculation of f7.
syms a0 a1 a2 a3 a4 a5
v = [0 2 4 6 8 10]
f = [0 2.9 14.8 39.6 74.3 119]
f1 = a0 + a1*v(1) + a2*v(1)^2 + a3*v(1)^3 + a4*v(1)^4 + a5*v(1)^5 == 0
f2 = a0 + a1*v(2) + a2*v(2)^2 + a3*v(2)^3 + a4*v(2)^4 + a5*v(2)^5 == 2.9
f3 = a0 + a1*v(3) + a2*v(3)^2 + a3*v(3)^3 + a4*v(3)^4 + a5*v(3)^5 == 14.8
f4 = a0 + a1*v(4) + a2*v(4)^2 + a3*v(4)^3 + a4*v(4)^4 + a5*v(4)^5 == 39.6
f5 = a0 + a1*v(5) + a2*v(5)^2 + a3*v(5)^3 + a4*v(5)^4 + a5*v(5)^5 == 74.3
f6 = a0 + a1*v(6) + a2*v(6)^2 + a3*v(6)^3 + a4*v(6)^4 + a5*v(6)^5 == 119
solve (f1, f2, f3, f4, f5, f6)
% Lorsque le projectile se déplace à la vitesse de 750 ft/sec, la force de
% ce même projectile est :
v(7) = 750;
% Calcul de la force
f7 = a0 + a1*v(7) + a2*v(7)^2 + a3*v(7)^3 + a4*v(7)^4 + a5*v(7)^5

Answers (2)

Torsten
Torsten on 24 Feb 2025
Edited: Torsten on 24 Feb 2025
Replace
solve (f1, f2, f3, f4, f5, f6)
by
[a0,a1,a2,a3,a4,a5] = solve (f1, f2, f3, f4, f5, f6)
But note that extrapolating the function from the interval [0 10] for v to v = 750 is doubtful.
  1 Comment
Jothi
Jothi on 24 Feb 2025
Ok, thanks for the answer !

Sign in to comment.


Walter Roberson
Walter Roberson on 24 Feb 2025
Edited: Walter Roberson on 24 Feb 2025
syms a0 a1 a2 a3 a4 a5
v = [0 2 4 6 8 10]
v = 1×6
0 2 4 6 8 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
f = [0 2.9 14.8 39.6 74.3 119]
f = 1×6
0 2.9000 14.8000 39.6000 74.3000 119.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
f1 = a0 + a1*v(1) + a2*v(1)^2 + a3*v(1)^3 + a4*v(1)^4 + a5*v(1)^5 == f(1)
f1 = 
f2 = a0 + a1*v(2) + a2*v(2)^2 + a3*v(2)^3 + a4*v(2)^4 + a5*v(2)^5 == f(2)
f2 = 
f3 = a0 + a1*v(3) + a2*v(3)^2 + a3*v(3)^3 + a4*v(3)^4 + a5*v(3)^5 == f(3)
f3 = 
f4 = a0 + a1*v(4) + a2*v(4)^2 + a3*v(4)^3 + a4*v(4)^4 + a5*v(4)^5 == f(4)
f4 = 
f5 = a0 + a1*v(5) + a2*v(5)^2 + a3*v(5)^3 + a4*v(5)^4 + a5*v(5)^5 == f(5)
f5 = 
f6 = a0 + a1*v(6) + a2*v(6)^2 + a3*v(6)^3 + a4*v(6)^4 + a5*v(6)^5 == f(6)
f6 = 
sol = solve([f1, f2, f3, f4, f5, f6])
sol = struct with fields:
a0: 0 a1: 137/80 a2: -1147/960 a3: 127/192 a4: -269/3840 a5: 1/384
% Lorsque le projectile se déplace à la vitesse de 750 ft/sec, la force de
% ce même projectile est :
v(7) = 750;
% Calcul de la force
f7 = subs(a0 + a1*v(7) + a2*v(7)^2 + a3*v(7)^3 + a4*v(7)^4 + a5*v(7)^5, sol)
f7 = 

Tags

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!