Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Improove sym subs on calculation delay
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi everybody
I am using a sym script with Variable : lamb. Problem is that final equation is heavy, and I ask to derivate it twice. When I use subs to evaluate it...it take time : 15 sec for 50 points.
clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%% Constante value for calculation %%%%%%%%%%%%%%%%%%%%
c= 299792458;
r=27.5;
T=680;
Pression_bar=1;
a=2.405*2.405;
c=3e8;
rc=r.*1e-6; %en m
T=T.*1e-9;% en m
n_g=1.45;
Pression_Pa=Pression_bar*1e5;
Pression_atm=101325;
pgas=Pression_bar *1e5;
A1=0.05792105;
A2=238.0185;
B1=0.00167917;
B2=57.362;
C1=0;
C2=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lamb = sym('lamb') ;
ngas= 1 + pgas/101325.* ( (A1 ./ (A2-(lamb.*1e6).^-2) ) + (B1 ./ (B2-(lamb.*1e6).^-2) ) + (C1 ./ (C2-(lamb.*1e6).^-2) )); %ARGON
k_0= 2*pi./(lamb);
epsi= n_g.^2 ./ ngas.^2;
phi = k_0*T* sqrt(n_g.^2-ngas.^2) ;
A=a./( 2.*ngas .*(k_0.*rc).^2);
B=a./ ( ngas.^2 .*(k_0.*rc).^3 );
C = epsi;
D = 0.5 .* (C+1) ./ sqrt(C-1);
nef= ngas - A - B.*D.*cot(phi);
dn = diff(nef,lamb);
dn2 = diff(dn,lamb);
dn3 = diff(dn2,lamb);
beta2=lamb.^3.*dn2./(2*pi*c.^2);
beta3=-lamb.^4./(2*pi*c).^2 .*(3.*dn2./c + lamb.*dn3./c);
lambb=linspace(800,1200,50).*1e-9;
tic
GVD=double(subs(beta2,lambb));
TOD=double(subs(beta3,lambb));
toc
I don't know if I am using properly sym? and Subs?
I try to use function.handle with : f=@(lamb) .... but I was not able to derivate it after
One of my collegue tells me that a parallel calculation can help?
Regards
M
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!