Guessing the values of a function by using initial values

Hey there,
I have been trying to use Newton Raphson method in order to get Matlab to guess some unknowns of a function. Hovewer, I did not have any luck doing that. Is there a better way to guess the values of a function?
Also the function I am working on is "f(x,y)=x-((28+y)/2)". And the initial values are; x_init=26.94 y_init=25.87.
Is it a right approach to use Newton Raphson method, or is there a way in Matlab to guess the variables of a function?

6 件のコメント

Torsten
Torsten 2022 年 8 月 3 日
You have two variables and only one function. How do you want to apply Newton-Raphson here ?
Ahmet Emre
Ahmet Emre 2022 年 8 月 3 日
There is a way to use Newton-Raphson for multivariable functions, but using that did not help me solve this problem. I believe it is because it required more than one function to get a solution.
Torsten
Torsten 2022 年 8 月 3 日
編集済み: Torsten 2022 年 8 月 3 日
Yes, in general, it requires as many function as there are variables to be solved for.
So I don't understand what you are trying to do.
Find a pair of numbers (x,y) for which f(x,y) = 0 ?
Compute f(x,y) for several values of x and y ?
Ahmet Emre
Ahmet Emre 2022 年 8 月 4 日
There is a software called "Engineering equation solver" or EES for short. It uses Newton-Raphson to guess the unknown values of some equations. It does that by using some initial values. I am trying to set up a similar approach in Matlab.
Torsten
Torsten 2022 年 8 月 4 日
編集済み: Torsten 2022 年 8 月 5 日
In parameter estimation, you usually have more equations than unknown. The usual Newton-Raphson does not apply in this case.
Look up "Gauss-Newton-algorithm" for more details:
In MATLAB, the functions "lsqlin" (for linear problems) or "lsqcurvefit" (for nonlinear problems) should do what you want.
Ahmet Emre
Ahmet Emre 2022 年 8 月 5 日
Thank you for the answer, I'll check that function

サインインしてコメントする。

回答 (1 件)

Les Beckham
Les Beckham 2022 年 8 月 3 日
編集済み: Les Beckham 2022 年 8 月 3 日

0 投票

You don't have to "guess" the values of the function, you can just calculate them.
Example
x = [-20:.1:20];
y = x;
[X,Y] = meshgrid(x, y);
f = @(x,y) x-((28+y)/2)
f = function_handle with value:
@(x,y)x-((28+y)/2)
Z = f(X,Y);
h = surf(X,Y,Z);
h.EdgeColor = 'none';
If you are trying to find the zeros of the function, that is a different question.

2 件のコメント

Ahmet Emre
Ahmet Emre 2022 年 8 月 3 日
I also need to run this in an iteration to get every calculated value of x and y and assign those to separate arrays. Say, to create an 1x64 array. That way, I will be able to solve my problem. I guess the solution you provided only gives certain points. This is the reason I was curious if it would somehow be possible to create "guess values". Thank you, by the way.
Les Beckham
Les Beckham 2022 年 8 月 3 日
You are welcome.
I'm afraid I still don't understand what you are trying to do.

サインインしてコメントする。

製品

リリース

R2022a

質問済み:

2022 年 8 月 3 日

編集済み:

2022 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by