How to plot a nonlinear equation using FSOLVE in MATLAB
Afficher commentaires plus anciens
Hello
I have a nonlinear equation like this:

in which:
I want to plot
vs. k
obviously this is a nonlinear equation. How should I use FSOLVE to have this plot?
Réponse acceptée
Plus de réponses (3)
Torsten
le 7 Mai 2019
0 votes
K = 1:627;
kp = 4500;
h = 1.0e-3;
d = 7.5e-3;
ky0 = 1.0;
Ky = zeros(numel(K),1);
%fKy = zeros(numel(K),1);
for i = 1:numel(K)
k = K(i);
fun = @(ky) ky/k*tan(ky*h)+(1-(k^2-ky^2)/(kp^2+k^2-ky^2))*tan(k*d)+(k^2-ky^2)/(kp^2+k^2-ky^2)*sqrt(kp^2-k^2)/k*tan(sqrt(kp^2-ky^2)*d);
Ky(i) = fzero(fun,ky0);
%fKy(i) = fun(Ky(i));
ky0 = Ky(i);
end
plot(K,Ky)
%plot(K,fKy)
mohammaddmt
le 7 Mai 2019
0 votes
3 commentaires
John D'Errico
le 7 Mai 2019
Please stop adding answers just to make a comment.
John D'Errico
le 7 Mai 2019
Anyway, I just spent what, well over an hour writing a solution to the problem that you posed, i.e., how to use fsolve to plot the solutions of an equation. Since fsolve only returns real solutions, that question was actually irrelevant, as was much of my solution as written.
Is there a good reason why you did not tell us what you really wanted to learn, and thus save me a great deal of time in answering the wrong question?
mohammaddmt
le 7 Mai 2019
Modifié(e) : mohammaddmt
le 7 Mai 2019
Mahmoud Abdelaziz
le 23 Déc 2019
0 votes
Hi there,
I see an excellent and helpfull answer.
I have a question. Can you help me.
I want to plot some nonlinear inequalities as follows:
R1>0,R2<0,R3>0,R4>0,R5>0,R6>0, where
R1= x*y+2, R2=x-1, R3=x^2*y-x*y-1, R4=x^2*y-x*y+2, R5=x*y+3, R6=x^3*y-4*x^2*y+3*x^2+4*x*y-8*x+8.
If not possible to plot these inequalities and find the region of solutions, Can plot them as equations?
Thank youfor your help.
M. A. M. Abdelaziz.
1 commentaire
John D'Errico
le 24 Déc 2019
Modifié(e) : John D'Errico
le 24 Déc 2019
Ask this as a separate question. What you have posted is not an answer, but a question.
By the way, what you have shown are NOT inequalities, but equalities. There is a difference, a big one. There is no region of solution to what you have posted, where they are equality statements.
Regardless, if you want help, post this as a QUESTION.
Catégories
En savoir plus sur Solver Outputs and Iterative Display 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!


