How can i do optimization in matlab?

Hi,
I have an equation given below
y = x- at
'x' and 't' are known value. I also have field value 'z'that is known.
I want to find the value of 'a' in the equation such that error between obtained 'y' and field value 'z' is minimum.
How can i do this in matlab? I am not sure of which optimization technique in matlab can be used.
Thanks, Menaka

6 Commenti

What are sizes of a and t?
Azzi Abdelmalek
Azzi Abdelmalek il 14 Feb 2013
Modificato: Azzi Abdelmalek il 14 Feb 2013
What is field z? It does not appear in your equation
Meenu
Meenu il 14 Feb 2013
Hi friend ,
sorry I was wrong before. I have changed the question now.
x and z are 1D array of ten points. a and t are single value.
Thanks
Meenu
Meenu il 14 Feb 2013
'z' is the field values measured. 'x' is the value obtained using my model.
I need to find 'y' values using 'x', but the obtained 'y' should have minimum error when compared with z values.
I want to find the values
'z' is nowhere to be found in your equation.
Meenu
Meenu il 15 Feb 2013
z is the array of reference values. I want to find y values using x values using the equation. I want an optimal value for 'a' so that RMSE between obtained values y and reference values z should be minimum. z is the reference value. it is not included in the equation.

Accedi per commentare.

Risposte (2)

José-Luis
José-Luis il 14 Feb 2013
Modificato: José-Luis il 14 Feb 2013
Are you sure you asked the right question? If so, what you are asking is:
y-x = at; %Find a and t
Since y and x are known, this can be written as
some_value = at;
This has an infinite number of solutions, or none at all if a or t are equal to zero and some_value is not. Just pick whatever value for a and calculate t. Or vice-versa.
If what you mean was a linear regression then:
coeff = polyfit(x,y,1);

1 Commento

Meenu
Meenu il 14 Feb 2013
my question was wrong before friend.I have changed the question.

Accedi per commentare.

Let me try to guess what you are doing. You have a bunch of input data you call x, and a bunch of output data you call z. There is a scalar 'a' and another piece of input data t so that, approximately, for each index i,
z(i) = x(i) - a*t(i)
You want to find the value of 'a' that makes this equation as true as possible, such as minimizing the sum of the squared differences.
If I am correct, write your equation as
a*t = z - x,
where t, z, and x are column vectors. The solution is
a = (z-x)\t
For more information, see the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation

1 Commento

Meenu
Meenu il 15 Feb 2013
the equation should be
y(i) = x(i) - a*i or y(t) = x(t) - a*t
where i= 1,2,3,.....
I have a bunch of input data you call x, and a bunch of reference data z. I want to find y as the output for each x using abouve equation. I need to find optimal value for 'a' such that RMSE between resulting y and z values should be minimum.
I can do this in MS.excel using solver. but I need to implement this in matlab.

Accedi per commentare.

Richiesto:

il 14 Feb 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by