How to solve numerically and find the smallest value?

8 Ansichten (letzte 30 Tage)
SAM
SAM am 10 Jan. 2023
Beantwortet: Rik am 10 Jan. 2023
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)

Akzeptierte Antwort

Rik
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 = 
0.00000000000000022204460724851781039709854611978
Solution=vpasolve(R1-R2==0,v,[0.1 0.9])
Solution = 
0.38634866606689403108165617379516
fplot(R1-R2)

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by