fsolve with independent functions
이전 댓글 표시
Hello, guys.
I've got some questions about 'fsolve'. The situation is following.
There is function handle matrix and its element function is independent each other. The reason why I put the functions into elements in the matrix is only I want to avoid very slow for-loop. In addition... Due to different output according to different x0, I duplicated function handle and made x0 matrix of different values for investigating multiple solutions.
In short, I used fsolve on the matrix of the independent functions.
The problem is that fsolve judges the state on results (w.r.t exitflag) integrally. 'Equation solved' message was displayed if every single (not partial) element equation was solved. So exitflag is always a single value, not a matrix. To make matters worse, there is no case of exitflag=-3 in R2012a.
I think there might be no solution in some elements as specfic x0 elements. In the case, I would only ignore them. (I don't wanna obsess that.) Could I get the results with exitflag matrix of independent elements?
eplasmafre=[4.7176e+12 4.2953e+12 3.5814e+12;2.5148e+12 1.7696e+10 5.2964e+12];
vthe=[1.6477e+06 1.6477e+06 1.6477e+06;1.6477e+06 1.6477e+06 1.6477e+06];
[meshx,meshy]=size(eplasmafre);LightVel=3e8;RFangFrequency=2*pi*13.56*1e6;
ScanDetail=[1 4 7];ScanDetailNum=length(ScanDetail);
ScanOrder=3:9;ScanOrderNum=length(ScanOrder);
ScansetNum=ScanDetailNum.*ScanOrderNum;Scanset=(reshape((ScanDetail'*(10.^(ScanOrder))),1,ScansetNum))';
eplasmafreScan=repmat(eplasmafre,[ScansetNum,1]);vtheScan=repmat(vthe,[ScansetNum,1]);
ScansetScan=sort(repmat(Scanset,meshx,meshy));
FtnforStocFre=@(Xfre)(1e8.*((4.*((LightVel./eplasmafreScan).*sqrt(2.*(1+((Xfre.^2)./(RFangFrequency.^2)))./(1+sqrt(1+((Xfre.^2)./(RFangFrequency.^2))))))./vtheScan).*((1./pi).*((exp(4.*(((LightVel./eplasmafreScan).*sqrt(2.*(1+((Xfre.^2)./(RFangFrequency.^2)))./(1+sqrt(1+((Xfre.^2)./(RFangFrequency.^2)))))).^2).*(RFangFrequency.^2)./(pi.*(vtheScan.^2))).*(1+(4.*(((LightVel./eplasmafreScan).*sqrt(2.*(1+((Xfre.^2)./(RFangFrequency.^2)))./(1+sqrt(1+((Xfre.^2)./(RFangFrequency.^2)))))).^2).*(RFangFrequency.^2)./(pi.*(vtheScan.^2)))).*expint((4.*(((LightVel./eplasmafreScan).*sqrt(2.*(1+((Xfre.^2)./(RFangFrequency.^2)))./(1+sqrt(1+((Xfre.^2)./(RFangFrequency.^2)))))).^2).*(RFangFrequency.^2)./(pi.*(vtheScan.^2)))))-1))-Xfre./((Xfre.^2)+(RFangFrequency.^2))));
options=optimset('Display','iter','TolFun',1e-20,'PlotFcns',@optimplotfval);
[solmat,~,exitflag,output]=fsolve(FtnforStocFre,ScansetScan,options);
댓글 수: 1
Walter Roberson
2012년 6월 18일
Please consider adding some blank lines in the code, as everything just runs together.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!