fsolve with independent functions
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 18 Juin 2012
Please consider adding some blank lines in the code, as everything just runs together.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!