problems with a trascendental equation
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
alburary daniel
el 10 de Jun. de 2018
Comentada: Walter Roberson
el 27 de Jul. de 2018
I tried all day to run my program
syms R t;
eqn = R*tan(10022.99039*R)-(6.97964*10^-3*sqrt(t))/R==0 ;
m = linspace(10,20,1) ;
sol = zeros(size(t)) ;
for i =1 :length(m)
eqn = subs(eqn,t,m(i)) ;
sol(i) = double(solve(eqn,R)) ;
end
plot(m,sol)
but matlab give me the issues
Error using mupadmex
Internal error with symbolic engine. Quit and restart MATLAB.
Error in sym>cell2ref (line 1303)
S = mupadmex(y);
Error in sym>tomupad (line 1241)
S = cell2ref(numeric2cellstr(x));
Error in sym (line 215)
S.s = tomupad(x);
Error in syms (line 197)
toDefine = sym(zeros(1, 0));
Error in SOLUCION1 (line 3)
syms R t;
any suggestion ?
1 comentario
Respuesta aceptada
John D'Errico
el 10 de Jun. de 2018
Editada: John D'Errico
el 10 de Jun. de 2018
You probably need to start with the basic tutorials to learn MATLAB. For example, you do this:
m = linspace(10,20,1)
m =
20
Then you run a loop for the length of m. m is a scalar. You have not created a vector at all.
You do other strange things, like this:
sol = zeros(size(t)) ;
But t is a scalar symbolic variable. Why do you think you need to preallocate sol as a scalar variable?
Next, you try to use solve on eqn.
pretty(vpa(eqn,5))
0.0069796 sqrt(t)
R tan(10023.0 R) - ----------------- == 0.0
R
Here, t takes on ONLY the value 20, so lets look at eqn after the subs.
pretty(vpa(subs(eqn,t,20),5))
0.031214
R tan(10023.0 R) - -------- == 0.0
R
Now, admittedly, this will be poorly scaled, because you are multiplying R by 10023, and THEN taking the tangent. And there will be infinitely many solutions.
So lets look at your problem. PLOT IT.
fun = @(R,t) R.*tan(10022.990390000000843429006636143*R) - (0.006979639999999999629143321300262*sqrt(t))./R
fun =
function_handle with value:
@(R,t)R.*tan(10022.990390000000843429006636143*R)-(0.006979639999999999629143321300262*sqrt(t))./R
ezplot(@(R) fun(R,20),[.001 .075])
refline(0,0)
Hmm. Lets zoom in way tighter. Even in that area where there appear to be no solutions...
ezplot(@(R) fun(R,20),[.038 .045])
Do you see each of those spikes that zooms up to infinity on the y axis? Each of them crosses zero. So now lets just pick some small region:
ezplot(@(R) fun(R,20),[.041 .042])
So there are infinitely many solutions. Just no way to write them all down. It is not like they will be equally spaced, either. Sorry, but the reason the solve tools crapped out is your problem has essentially no solution, in the sense that there are infinitely many solutions, but no way to represent them.
So, can you solve this? NO. Yes, you can use fzero, and find any specific root. Or, for that matter, you can use vpasolve, and find ONE root. But you need to think about what you are doing. You need to plot the stuff you are trying to solve. Don't just throw stuff at a solver and expect it to magically return all of infinitely many solutions at you. Apply common sense.
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!