Syms equation in GUI to @ equation solver

1 次查看(过去 30 天)
Hello, I write a GUI on Matlab 2020 with all the Toolbox, but need to work also on a Matlab 2007 without all the Toolbox.
Currently I use :
function [dt] = DeltaT(lambda0,c,deltaLambdaSPM,tfwhm)
dtlim=lambda0/2/c %% lower limit
syms x
A=c*lambda0*2*x/(2*c*x-lambda0);
B=c*lambda0*2*x/(2*c*x+lambda0);
C=A-B;
eqn=C==7*deltaLambdaSPM;
varLimits(1,1) = dtlim;
varLimits(2,1)=tfwhm/5 ;
S = vpasolve([eqn],x,varLimits);
dt=double(S);
end
With Matlab 2020 + Toolbox it's working, not with the other.
So I try to modify it
lambda0=1030e-9;
c=3e8;
tfwhm=500e-15;
deltaLambdaSPM=1.35e-06;
dtlim=lambda0/2/c;
fun = @(x) c*lambda0*2*x./(2*c*x-lambda0)- c*lambda0*2*x./(2*c*x+lambda0) - 7*deltaLambdaSPM
x0 = [dtlim tfwhm/5];
z = fzero(fun,x0)
%%
Error using fzero (line 229)
Function values at interval
endpoints must be finite and
real.
Error in testesuationsolver
(line 17)
z = fzero(fun,x0)
I try also fsolve...
solution should be : 1.9e-15
If someone have an idea?
Regards

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by