Solve a numerical function

I am trying to solve a numerical equation with three unkonown values Ge, G and t , thse values will be approximated by fitting the curve with the from equation (Gp) to the following data obtained.
This means that is possible to make a curve approximation in order to know the values of the G anf t terms, depending on the number of terms desired for the sum.
I would really appreciate if someone could help me please. Here is the code and the data:
clear all, close all
data1=[0.010931641 0.011369615 0.012298683];
data2=[691.5802655 719.3455778 778.7159258];
Gp=data2(1); wp=data1(1);
for i=1:11
Gp=Ge+(G(i)*wp^2*t(i)^2)/(1+wp^2*t(i)^2)
end

3 Comments

You have 3 unknown variables, but only 1 equation to describe the relationship. Can you provide more information about the problem?
Gp = Ge + (G*wp²*t²)/(1 + wp²*t²)
(Gp – Ge)*(1 + wp²*t²) = G*wp²*t²
(Gp – Ge)*(1/(wp²*t²) + 1) = G
It is a curve fitting problem. You can solve for three variables if you have 3 or more points, each of which generates an implicit equation.
I already have an experimental curve, Gp as a function of w of which I tried to determine these variables by fitting it with this equation.
How can I solve this problem of fitting curve.

Sign in to comment.

Answers (1)

Hi Issam
From the advice of Mr. Roberson, you can create 3 equations from the data points:
691.5802655 = Ge + (G*0.010931641²*t²)/(1 + 0.010931641²*t²);
719.3455778 = Ge + (G*0.011369615²*t²)/(1 + 0.011369615²*t²);
778.7159258 = Ge + (G*0.012298683²*t²)/(1 + 0.012298683²*t²);
and then solve them simultaneously to obtain the solutions for the 3 variables:
Ge ≈ 260.642
G ≈ 2166.56
t ≈ ±45.5822

5 Comments

Hi Sam,
Please is there any code on Matlab to solve this equation for 11 variables.
Thanks in advance
Hi Issam
If you have 11 equations (required to solve for 11 variables), then you can use the code involving the fsolve function as shown here:
Else, you can consult with Mr. @Walter Roberson if there is a better way for solving for 11 variables.
Hi Mr. Walter,
I tried to solve this problem by following this code to determined variables Ge G1 t1 t2 G2:
syms Ge G1 t1 G2 t2;
w=[0.010931641 0.011369615 0.012298683];
Gp=[691.5802655 719.3455778 778.7159258];
E1= (Ge - Gp(1) + (G1*t1^2*w(1)^2)/(t1^2*w(1)^2 + 1)+(G2*t2^2*w(1)^2)/(t2^2*w(1)^2 + 1));
E11=(- Gp(1) + (G1*t1^2*w(1)^2)/(t1^2*w(1)^2 + 1)+(G2*t2^2*w(1)^2)/(t2^2*w(1)^2 + 1));
E2=(Ge - Gp(2) + (G1*t1^2*w(2)^2)/(t1^2*w(2)^2 + 1)+(G2*t2^2*w(2)^2)/(t2^2*w(2)^2 + 1));
E22=(- Gp(2) + (G1*t1^2*w(2)^2)/(t1^2*w(2)^2 + 1)+(G2*t2^2*w(2)^2)/(t2^2*w(2)^2 + 1));
E3=(Ge - Gp(3) + (G1*t1^2*w(3)^2)/(t1^2*w(3)^2 + 1)+(G2*t2^2*w(3)^2)/(t2^2*w(3)^2 + 1));
E33=(- Gp(3) + (G1*t1^2*w(3)^2)/(t1^2*w(3)^2 + 1)+ (G2*t2^2*w(3)^2)/(t2^2*w(3)^2 + 1));
sol = solve(E1,E11,E2,E22,E3,E33, Ge, G1, t1, G2, t2)
But it is giving me the error
sol =
Ge: [16x1 sym]
G1: [16x1 sym]
t1: [16x1 sym]
G2: [16x1 sym]
t2: [16x1 sym]
May you help me please
I only see two solutions.
In any case, why do you think that is an error?
syms Ge G1 t1 G2 t2;
w=[0.010931641 0.011369615 0.012298683];
Gp=[691.5802655 719.3455778 778.7159258];
E1= (Ge - Gp(1) + (G1*t1^2*w(1)^2)/(t1^2*w(1)^2 + 1)+(G2*t2^2*w(1)^2)/(t2^2*w(1)^2 + 1));
E11=(- Gp(1) + (G1*t1^2*w(1)^2)/(t1^2*w(1)^2 + 1)+(G2*t2^2*w(1)^2)/(t2^2*w(1)^2 + 1));
E2=(Ge - Gp(2) + (G1*t1^2*w(2)^2)/(t1^2*w(2)^2 + 1)+(G2*t2^2*w(2)^2)/(t2^2*w(2)^2 + 1));
E22=(- Gp(2) + (G1*t1^2*w(2)^2)/(t1^2*w(2)^2 + 1)+(G2*t2^2*w(2)^2)/(t2^2*w(2)^2 + 1));
E3=(Ge - Gp(3) + (G1*t1^2*w(3)^2)/(t1^2*w(3)^2 + 1)+(G2*t2^2*w(3)^2)/(t2^2*w(3)^2 + 1));
E33=(- Gp(3) + (G1*t1^2*w(3)^2)/(t1^2*w(3)^2 + 1)+ (G2*t2^2*w(3)^2)/(t2^2*w(3)^2 + 1));
sol = solve(E1,E11,E2,E22,E3,E33, Ge, G1, t1, G2, t2)
sol = struct with fields:
Ge: [2×1 sym] G1: [2×1 sym] t1: [2×1 sym] G2: [2×1 sym] t2: [2×1 sym]
vpa(subs([Ge, G1, t1, G2, t2], sol))
ans = 
Thanks for the help Mr. Walter

Sign in to comment.

Asked:

on 26 May 2022

Commented:

on 30 May 2022

Community Treasure Hunt

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

Start Hunting!