Borrar filtros
Borrar filtros

Finding solutions of a transcendental function

3 visualizaciones (últimos 30 días)
Denikka Brent
Denikka Brent el 4 de Nov. de 2018
Comentada: Denikka Brent el 4 de Nov. de 2018
I have a function:
cos(wbar)-(IT.*wbar.*sin(wbar))==0
I am trying to propose this in a graphical manner by finding the two lowest solutions of this function. The graph will be IT vs wbar where IT is a vector of 0 to 5.
Any help on this?

Respuesta aceptada

John D'Errico
John D'Errico el 4 de Nov. de 2018
Editada: John D'Errico el 4 de Nov. de 2018
What have you tried? If nothing, then why not?
First, create IT.
n = 100;
IT = linspace(0,5,n);
Initialize wbar. Use NaNs, so you know what has been done so far.
wbar = NaN(n,2);
Thus, two solutions for each element of IT.
Now it is just a loop, over the elements of IT. Note that for IT == 0, the first two solutions must be just pi/2 and3*pi/2. Because then the problem reduces to cos(wbar) == 0.
wbar(1,:) = [pi/2,3*pi/2];
But now, each value of IT is only slightly different from the last one. So the next pair of solutions must also be close to the last. Just loop.
for i=2:n
% at each step, just create a new function handle,
% encapsulating the current value for IT(i).
fun = @(w) cos(w) - IT(i)*sin(w);
wbar(i,1) = fzero(fun,wbar(i-1,1));
wbar(i,2) = fzero(fun,wbar(i-1,2));
end
plot(IT,wbar,'-')
grid on
Now, you can hand this in for your homework assignment, which would make it fairly clear that you got the code from someone online, or you can make some effort. But that would be your decision to make. So why not use some ideas from what I wrote here, then making an effort to write it on your own?
  1 comentario
Denikka Brent
Denikka Brent el 4 de Nov. de 2018
Thank you. I followed this and understood. I was so close to solving this but got an error when using fzero. I believe because I didn't initialize wbar.
Thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by