Hi Prasad,
To solve the given equations in MATLAB, you should make use of “fsolve” function. “fsolve” is a numerical solver for systems of non-linear equations. It attempts to find the values of variables that make a system of equations equal to zero. You can use it as follows:
- Write a function that returns the system of equations you need to solve. This function should take the unknown variables as inputs and return the values of the equations.
function F = equations(x, vc, a, omega, phi)
F(1) = vc * sin(phi) + a * omega * cos(omega * x(1));
F(2) = vc * sin(phi - omega * (x(1) - x(2))) + a * omega * cos(omega * x(2));
end
- Provide an initial guess for the variables. This helps “fsolve” start the search for a solution.
x0 = [0, 0]; % Initial guess
- Loop over the different phi values between the given range of 270 <= “phi” <= 360, within which use “fsolve” to find the values of the variables that satisfy the equations. Pass the function “equations” that we defined above, the initial guess, and any options you need to configure.
phi_range = deg2rad(270:360);
for i = 1:length(phi_range)
phi = phi_range(i);
x0 = [0, 0]; % Initial guess
options = optimset('Display', 'off');
[x_sol, ~] = fsolve(@(x) equations(x, vc, a, omega, phi), x0, options); % assuming values of vc, a and omega are pre-defined
t4_solutions(i) = x_sol(1); % refers to t4
t2_solutions(i) = x_sol(2); % refers to t2
end
This approach will allow you to find the solutions for “t4” and “t2” over a range of “phi” values using “fsolve”.
To know more about “fsolve”, you can refer to the following documentation link: