how to solve exponential equation
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everybody
I have got a mat file that I need to use output for the function. Each row of the mat file will be implemented to the function ( 100 of them) and then each result will be saved as one matrix. The code I used did not help. Can anyone help me out?
load('example.mat');
X = sym( nan(size(ee)) );
for K = 1 : numel(ee)
solution = vpasolve( 0.4075*exp(-((x(K)-14.87)/11.39).^2) + 0.5621*exp(-((x(K)-18.64)/27.74).^2, x));
if isempty(solution)
fprintf('No solution for a(%d)\n', K);
else
X(K) = solution;
end
end
The variable ee is coming from the mat file that I loaded.
Thanks!!!
0 Commenti
Risposta accettata
dpb
il 25 Mag 2019
Modificato: dpb
il 25 Mag 2019
opt= optimoptions('fsolve','Display','none');
X0=15;
soln=arrayfun(@(e) fsolve(@(x) fnE(x)-e,X0,opt),ee);
NB: There are two possible solutions; which one fsolve finds will depend on whether the initial guess is on the LH or RH side of the maximum; the one above finds the RH set; setting X0=13 (say) returns the other.
You give no information as to which is the desired set or if it matters.
2 Commenti
dpb
il 25 Mag 2019
Modificato: dpb
il 25 Mag 2019
"... I am aware that the values for y axis is symetrical...."
The y-values around the peak are NOT symmetrical -- the peak is the summation of two gaussians of differing means and variance so while each independently would be symmetric around its mean, the summation is not...the distribution with the higher mean also has almost 3X the magnitude of std as does the lower mean distribution. Hence it is spread far more and this shows up as a broader RH side as compared to LH if reflect the two halves around the peak location.
For the followup question--
You're solving for the point that the functional equals the value -- that isn't the maximum value of the function, it's the value on one or the other sides of the peak. Why would you expect anything else?
Plot the solution X and associated value on the curve and you'll just put X's or O's or whatever symbol of choice on the curve at the intersection points...
Perhaps this is the correct solution but not to the problem you actually were trying to solve???
Più risposte (1)
dpb
il 24 Mag 2019
fnE=@(x) 0.4075*exp(-((x-14.87)/11.39).^2) + 0.5621*exp(-((x-18.64)/27.74).^2);
ezplot(fnE,[0 100])
hAx=gca;
hL=hAx.Children;
>> yMx=max(hL.YData)
yMx =
0.9612
>> sum(ee<=yMx)
ans =
0
>> min(ee)
ans =
0.9626
>>
The function maximum is roughly 0.9612; the minimum value in you array is 0.9626; there are no values that will solve the equation given the constants...gets fairly close, but can't quite get there...
>> fminsearch(@(x) -fnE(x),15)
ans =
15.5765
>> fnE(ans)
ans =
0.9612
>>
8 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!