Solve equation without symbolic math toolbox

144 visualizaciones (últimos 30 días)
Benoit
Benoit el 19 de Mzo. de 2014
Comentada: Paul el 12 de Oct. de 2025 a las 19:55
Hello ,
I'm trying to solve this equation : 0 = (U/r.^3)* sqrt(-2+((3*r.^3)*(Bx/U)))-B
U is a constant
Bx and B are column matrix
I would have as a result a value of r for each value of Bx and B
is it possible to do this without the Symbolic math toolbox ?
Thank you

Respuesta aceptada

Chris C
Chris C el 19 de Mzo. de 2014
You can run this with two functions. The first function I have designated as myMain.m and it is written as..
r0 = rand(3,3);
fsolve(@myfun,r0)
The second function myfun.m is called by the first function by passing initial guesses of r as r0. I altered the way your equation above was written and wrote the function as...
function F = myfun(r)
Bx = rand(3,1);
B = rand(3,1);
U = rand(1);
F = (U)*sqrt(-2+((3*r.^3)*(Bx/U)))-r.^3*B;
end
Change the matrices to whatever numbers you need and it should work.
Good luck.
  2 comentarios
Benoit
Benoit el 20 de Mzo. de 2014
Movida: John D'Errico el 4 de Sept. de 2025
Hello,
Thank you for reactivity, I've tried you're solution. Im new to fsolve function so maybe I am missing something but your answer gives me just one solution.
Benoit
Benoit el 20 de Mzo. de 2014
Movida: John D'Errico el 4 de Sept. de 2025
Ok , i've got it.
Thank you

Iniciar sesión para comentar.

Más respuestas (1)

glady
glady el 4 de Oct. de 2025 a las 10:58
Two fair dice are thrown and the product of the numbers on the dice is recorded. Given that one die lands on 5, find the probability that the product on the dice is
(a) Exactly 15 =
(b) More than 12 =
  8 comentarios
Torsten
Torsten el 11 de Oct. de 2025 a las 17:56
Editada: Torsten el 11 de Oct. de 2025 a las 17:58
Google's AI supports Sam Chak's last interpretation and gives probabilities of 2/11 and 7/11 :-)
Paul
Paul el 12 de Oct. de 2025 a las 19:55
Well, we can't really trust AI w/o verification, can we? :-)
[D1,D2] = deal((1:6).');
S = combinations(D1,D2);
N = sym(height(S));
S.A1 = prod(S{:,"D"+(1:2)},2) == 15;
S.A2 = prod(S{:,"D"+(1:2)},2) > 12;
B1 = or(S.D1 == 5,S.D2 == 5); % at least one
B2 = S.D1 == 5; % one specific
B3 = xor(S.D1 == 5,S.D2 == 5); % exactly one
S.B = [B1,B2,B3];
PA1gB = (sum(S.A1 & S.B,1)/N) ./ (sum(S.B,1)/N)
PA1gB = 
PA2gB = (sum(S.A2 & S.B,1)/N) ./ (sum(S.B,1)/N)
PA2gB = 

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by