Rank: 106 based on 702 downloads (last 30 days) and 28 files submitted
photo

Miroslav Balda

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Miroslav View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
18 Feb 2014 Screenshot SINIDE - Parameter identification of a sine-wave from a measured signal Frequency, amplitude, phase shift and mean value of the best sinus fit to a sampled signal. Author: Miroslav Balda signal processing, parameter identificat..., harmonic process 34 0
23 Apr 2013 Screenshot LMFnlsq2 Solution of one or more nonlinear equations in the least squares sense. Author: Miroslav Balda nonlinear least squar..., curve fitting, identification, optimization, measurement 39 10
  • 5.0
5.0 | 4 ratings
16 Jul 2012 Screenshot GETK Wait for and identify a pressed key Author: Miroslav Balda waiting, keyboard, keys, control design, measurement, optimization 14 0
25 Feb 2012 Soft interrupting of long computer runs Long run of the program can be interrupted without any loss of data in a workspace. Author: Miroslav Balda run interrupt, cycle interrupt, demo, optimization, simulation, gui 12 0
25 Feb 2012 Screenshot LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda optimization, levenberg, marquardt, fletcher, least squares, fig and separator 115 44
  • 4.58333
4.6 | 30 ratings
Comments and Ratings by Miroslav View all
Updated File Comments Rating
14 Feb 2014 Frequency, amplitude, phase and mean value of sine wave The function sinfapm evaluates parameters of sampled sine wave Author: Miroslav Balda

@Will
I am sorry that the function behaved wrong. A reason for it was a hight sensitivity of the function to inaccurate initial guess of the sought parameters. Since it was impossible to improve it by little modification, I decided to build a new function. It will appear in a short time under the name sinide.m.

03 Jan 2014 LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda

Sorry, I repair a wrong copying.
The right solutions are
x =
-0.0000
1.0000
ssq =
2.6880e-009
cnt =
149
===================
x =
0.0000
1.0000
ssq =
1.2586e-021
cnt =
4
===================
x =
0.0000
1.0000
ssq =
1.2586e-021
cnt =
4

Miroslav

02 Jan 2014 LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda

Dear Amin
I thank you for your interest in my function LMFnlsq. The difference in solutions between LMFnlsq and fminsearch is caused by default preset tolerances 'XTol' and FunTol'.By changing them, you would obtain just the same result. It is obvious from the first group of results from the script Amin.m with improved required tolerances:
% Amin.m
%%%%%%%%% 2014-01-03
clc
clear all
close all
format compact

y =@(x) x^2+1;
c =@(x) complex(x(1),x(2));
fx=@(x) abs(y(c(x)));

[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5],'XTol',1e-10,'FunTol',1e-10)

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
fx=@(x) [real(y(c(x))); imag(y(c(x)))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
c = @(x) complex(x(1),x(2))^2;
fx = @(x) [real(c(x))+1; imag(c(x))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

Solutions of all cases are:

% Amin.m
%%%%%%%%% 2014-01-03
clc
clear all
close all
format compact

y =@(x) x^2+1;
c =@(x) complex(x(1),x(2));
fx=@(x) abs(y(c(x)));

[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5],'XTol',1e-10,'FunTol',1e-10)

fprintf('===================\n');

% solution of 2 equations: Re f + 1; Im c^2 = 0;
fx=@(x) [real(y(c(x))); imag(y(c(x)))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
c = @(x) complex(x(1),x(2))^2;
fx = @(x) [real(c(x))+1; imag(c(x))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

The first solution corresponds the example solved by fminsearch, however, with smaler tolerances. The solution is the same.

If you wanted to solve the >>complex<< problem f(x) = x^2 + 1, then the anonymous functionsare different, and are given in example 2 and 3. It is clear that the almost exact solution is reached in only 4 steps (cnt).

All the best in the New Year!
Miroslav

09 Sep 2013 LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda

@Jose
There are no bugs in LMFnlsq and LMFnlsq2 that you have anounced. There is an error in the data, because all vectors x1, x2, x3, and y should be COLUMN vectors. More to it, the division operator in fun should be an array operator './'. The repaired code follows:

% Repaired data: Column vectors!
x1 = [470, 285, 470, 470, 470, 100, 100, 470, 100, 100, 100, 285, 285]';
x2 = [300, 80, 300, 80, 80, 190, 80, 190, 300, 300, 80, 300, 190]';
x3 = [ 10, 10, 120, 120, 10, 10, 65, 65, 54, 120, 120, 10, 120]';
y = [8.55, 3.79, 4.82, 0.02, 2.75, 14.39, 2.54, 4.35, 13.00, 8.50, 0.05, 11.32, 3.13]';
b0 = rand(5,1);
fun = @(b) (b(1)*x2 - x3/b(5))./(1 + b(2)*x1 + b(3)*x2 + b(4)*x3) - y; % ./
[C,ssq,cnt] = LMFnlsq2(fun, b0, 'Display',[-10,0], 'FunTol',1e-10);

26 Aug 2013 LMFnlsq2 Solution of one or more nonlinear equations in the least squares sense. Author: Miroslav Balda

@xinxing
Build M-function, say resid.m, for evaluation of problem residuals:

function res = resid(p)
%xxxxxxxxxxxxxxxxxxxxxx
global t Y Wp % Wp = penalty weight
% If you wish to work with the native names of variables (not with the elements of the sought parameters p(i), use the following command:
[A,B,C1,C2,m,w,Tc] = deal2('_elm_',p); % deal2 is the function from the File Exchange
% http://www.mathworks.com/matlabcentral/fileexchange/32547
Tct = Tc - t;
lTt = log(Tct);
res = [A + B*Tct.^m + C1*cos(w*lTt) + C2*sin(w*lTt) - Y
(B>0)*B*Wp
(abs(C1)>1)*(abs(C1)-1)*Wp
(abs(C2)>1)*(abs(C2)-1)*Wp
(Tc<=max(t))*(Tc-max(t))*Wp
(m<0.1)*(m+0.1)*Wp
(m>0.9)*(m-0.9)*Wp
(w<6)(w+6)*Wp
(w>13)*(w-13)*Wp];

The user should choose propper weight(s) of penalties expressing constraints put on parameters.

Comments and Ratings on Miroslav's Files View all
Updated File Comment by Comments Rating
13 Mar 2014 Frequency, amplitude, phase and mean value of sine wave The function sinfapm evaluates parameters of sampled sine wave Author: Miroslav Balda wehner, will

Thank you.
Unfortunately, I believe there are still problems with the function.

I emailed you an example (miroslav@balda.cz) with estimation of real data. It uses your function and compares to estimation with nlinfit.m

Will

14 Feb 2014 Frequency, amplitude, phase and mean value of sine wave The function sinfapm evaluates parameters of sampled sine wave Author: Miroslav Balda Balda, Miroslav

@Will
I am sorry that the function behaved wrong. A reason for it was a hight sensitivity of the function to inaccurate initial guess of the sought parameters. Since it was impossible to improve it by little modification, I decided to build a new function. It will appear in a short time under the name sinide.m.

30 Jan 2014 Frequency, amplitude, phase and mean value of sine wave The function sinfapm evaluates parameters of sampled sine wave Author: Miroslav Balda wehner, will

t=0:.01:1;
y=2*sin(2*pi*10*t+3)+5;

[f,a,phi,ave] = sinfapm(y,100)

Returns
f=2.486
a=-0.1283
phi=1.5719
ave=5.0035

03 Jan 2014 LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda Balda, Miroslav

Sorry, I repair a wrong copying.
The right solutions are
x =
-0.0000
1.0000
ssq =
2.6880e-009
cnt =
149
===================
x =
0.0000
1.0000
ssq =
1.2586e-021
cnt =
4
===================
x =
0.0000
1.0000
ssq =
1.2586e-021
cnt =
4

Miroslav

02 Jan 2014 LMFnlsq - Solution of nonlinear least squares Efficient and stable Levenberg-Marquard-Fletcher method for solving of nonlinear equations Author: Miroslav Balda Balda, Miroslav

Dear Amin
I thank you for your interest in my function LMFnlsq. The difference in solutions between LMFnlsq and fminsearch is caused by default preset tolerances 'XTol' and FunTol'.By changing them, you would obtain just the same result. It is obvious from the first group of results from the script Amin.m with improved required tolerances:
% Amin.m
%%%%%%%%% 2014-01-03
clc
clear all
close all
format compact

y =@(x) x^2+1;
c =@(x) complex(x(1),x(2));
fx=@(x) abs(y(c(x)));

[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5],'XTol',1e-10,'FunTol',1e-10)

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
fx=@(x) [real(y(c(x))); imag(y(c(x)))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
c = @(x) complex(x(1),x(2))^2;
fx = @(x) [real(c(x))+1; imag(c(x))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

Solutions of all cases are:

% Amin.m
%%%%%%%%% 2014-01-03
clc
clear all
close all
format compact

y =@(x) x^2+1;
c =@(x) complex(x(1),x(2));
fx=@(x) abs(y(c(x)));

[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5],'XTol',1e-10,'FunTol',1e-10)

fprintf('===================\n');

% solution of 2 equations: Re f + 1; Im c^2 = 0;
fx=@(x) [real(y(c(x))); imag(y(c(x)))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

fprintf('===================\n');

% solution of 2 equations: Re c^2 + 1; Im c^2 = 0;
c = @(x) complex(x(1),x(2))^2;
fx = @(x) [real(c(x))+1; imag(c(x))];
[x,ssq,cnt] = LMFnlsq(fx,[0.1;1.5])

The first solution corresponds the example solved by fminsearch, however, with smaler tolerances. The solution is the same.

If you wanted to solve the >>complex<< problem f(x) = x^2 + 1, then the anonymous functionsare different, and are given in example 2 and 3. It is clear that the almost exact solution is reached in only 4 steps (cnt).

All the best in the New Year!
Miroslav

Contact us