How to solve numerically and find the smallest value?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have the following code to numerically find the smallest intersection point between two curves. I used "vpasolve'' to find the solution and it is giving me 1. However, when I draw the two curves, there are other intersection points. Is there a way to solve numerically and find the smallest value?
thank you
clear;clc;close all
syms v L0 x
x=2;
A=sqrt(2)*x*v^(-.5)*(1-(1-v^2)^.5)^.5;
B=sqrt(2)*x*v^(-.5)*(1+(1-v^2)^.5)^.5;
R1=(A/B)^(3)*tan(A);
R2=tan(B);
Solution=vpasolve(R1-R2==0,v);
figure(2)
fplot(R1)
hold on
fplot(R2)
0 Kommentare
Akzeptierte Antwort
Rik
am 10 Jan. 2023
You can supply an initial estimate or a search range to vpasolve, as its documentation explains:
syms v L0 x
x=2;
A=sqrt(2)*x*v^(-.5)*(1-(1-v^2)^.5)^.5;
B=sqrt(2)*x*v^(-.5)*(1+(1-v^2)^.5)^.5;
R1=(A/B)^(3)*tan(A);
R2=tan(B);
Solution=vpasolve(R1-R2==0,v,eps) % supply eps() to get close to 0
Solution=vpasolve(R1-R2==0,v,[0.1 0.9])
fplot(R1-R2)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!