필터 지우기
필터 지우기

Syms equation in GUI to @ equation solver

조회 수: 2 (최근 30일)
Martin Maurel
Martin Maurel 2021년 3월 12일
댓글: Martin Maurel 2021년 4월 14일
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
  댓글 수: 2
Asvin Kumar
Asvin Kumar 2021년 3월 15일
fzero(dtlim) is Inf.
Martin Maurel
Martin Maurel 2021년 4월 14일
Your are right,
x0 = [1.00000001*dtlim tfwhm/5];
solve it

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by