MATLAB numerical evaluation

In summary: However, please note that this is just an example and you may need to adjust the function and boundary conditions to fit your specific problem.
  • #1
51
0
Hi!

Is it possible to solve the following problem in MATLAB or maple?

{d(phi)/d(lambda)}^2 = (sin(phi))^2 - (sin(phi_one))^2


I need to determine phi_one numerically given the following boundary conditions:

phi(0)=C1 (constant) and {d(phi)/d(lambda)} = 0 when lambda = C2 (constant).


How do I set this problem up using fsolve? I can't seem to enter the second boundary condition in matlab.

This is what I've done for solving the problem using dsolve
dsolve('Dy = sqrt((sin(y))^2 - (sin(y1))^2)', 'y(0)=pi/3', 'Dy(2)=0') where y is phi although Dy(2) is not how I have to enter the second boundary condition.

Would appreciate your help formulating this problem in Matlab as I've tried various tricks but to no avail.

Thanks!
 
Physics news on Phys.org
  • #2
Yes, it is possible to solve this problem in MATLAB using the fsolve function. The basic idea is to create a function which takes two parameters (in this case, phi and phi_one) and returns the value of the equation {d(phi)/d(lambda)}^2 = (sin(phi))^2 - (sin(phi_one))^2. Then, you can use fsolve to find the values of phi and phi_one that satisfy the boundary conditions.

Here is an example of how you could set up the function:

function f = equation(phi,phi_one)
f = (sin(phi))^2 - (sin(phi_one))^2 - (diff(phi))^2;
end

Then, you can use fsolve to solve the equation with the given boundary conditions. Here is an example of how to do that:

x0 = [pi/3; 0]; %initial guess for phi and phi_one
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(@equation,x0,options);

This should give you the values of phi and phi_one that satisfy the boundary conditions.
 
  • #3


Hello! Yes, it is possible to solve this problem using MATLAB or Maple. In fact, both programs have built-in functions specifically for solving numerical equations, such as fsolve in MATLAB and fsolve in Maple. To set up the problem in MATLAB using fsolve, you can follow these steps:

1. Define the function that represents your equation using the syntax @(x) (insert equation here). In this case, it would be @(x) (sin(x))^2 - (sin(phi_one))^2.
2. Define the initial guess for phi_one. This can be any value, but it is recommended to choose a value close to the expected solution.
3. Use the fsolve function with the syntax fsolve(@(x) (sin(x))^2 - (sin(phi_one))^2, initial_guess). This will give you the numerical solution for phi_one.
4. To incorporate the boundary conditions, you can use the syntax fsolve(@(x) (sin(x))^2 - (sin(phi_one))^2, initial_guess, options), where options is a structure that allows you to specify the boundary conditions. For example, you can use the 'Lower' and 'Upper' fields to set the lower and upper bounds for the solution, or you can use the 'Jacobian' field to specify the derivative of the function if it is not easily computed.
5. Once you have set up the problem and run the fsolve function, you can use the output to determine the numerical solution for phi_one.

I hope this helps! If you continue to have trouble, you can consult the documentation for fsolve or reach out to the MATLAB support team for further assistance. Good luck with your problem!
 

1. What is MATLAB numerical evaluation?

MATLAB numerical evaluation is the process of using MATLAB software to perform mathematical calculations and analyze data. It involves using numerical methods to solve equations, manipulate matrices, and plot graphs.

2. What are the benefits of using MATLAB for numerical evaluation?

MATLAB has a wide range of built-in functions and tools specifically designed for numerical evaluation. It also has a user-friendly interface and powerful visualization capabilities, making it a popular choice for scientists and engineers.

3. Can MATLAB handle complex numerical problems?

Yes, MATLAB has powerful algorithms and functions that can handle complex numerical problems such as solving differential equations, optimization, and signal processing.

4. How accurate are the numerical results obtained from MATLAB?

The accuracy of the results depends on the precision of the data entered and the algorithms used. MATLAB has the ability to perform calculations with high precision, but it is always important to check the accuracy of the results and adjust parameters if needed.

5. Can I use MATLAB for real-time numerical evaluation?

Yes, MATLAB has the capability to perform real-time numerical evaluation, making it useful for applications where data is continuously being collected and analyzed in real-time.

Suggested for: MATLAB numerical evaluation

Replies
5
Views
981
Replies
4
Views
441
Replies
13
Views
1K
Replies
4
Views
2K
Replies
5
Views
910
Replies
2
Views
2K
Replies
32
Views
2K
Replies
2
Views
1K
Replies
2
Views
636
Back
Top