Solving an equation in Matlab

  • Thread starter Belginator
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses an equation with variables E, Me, and gamma, and the goal is to find a matrix of 80 values of Me corresponding to a given matrix of E and a known gamma value. The suggested approach is to manipulate the equation and solve for Me using a function such as fsolve.
  • #1
Belginator
12
0

Homework Statement



Ok I have an equation:

E = (1/Me)*((2/(gamma+1))*(1+((gamma-1)/2)*Me^2))^((gamma+1)/(2*gamma-2));

Where is E is a matrix of [0:1:80] and gamma is known as 1.40.

What function do I use to solve for Me? I need to find a matrix of 80 values of Me each corresponding to the E value.

I have no idea what to use, I was going along the lines of fsolve, but I just don't know, any help would be very much appreciated.
 
Physics news on Phys.org
  • #2
Belginator said:

Homework Statement



Ok I have an equation:

E = (1/Me)*((2/(gamma+1))*(1+((gamma-1)/2)*Me^2))^((gamma+1)/(2*gamma-2));

Where is E is a matrix of [0:1:80] and gamma is known as 1.40.

What function do I use to solve for Me? I need to find a matrix of 80 values of Me each corresponding to the E value.

I have no idea what to use, I was going along the lines of fsolve, but I just don't know, any help would be very much appreciated.
Your equation is of the form
E = 1/Me*a*(1+b*Me^2)^c
So
(E.^1/c)/a = 1/Me +b*Me
Now, you should do some work.
 
  • #3


I would recommend using the "fsolve" function in Matlab to solve for Me in this equation. This function is specifically designed for solving nonlinear equations and can handle matrices as well. You can use the "fsolve" function by defining the equation as a function handle and providing initial guesses for Me. The output will be a matrix of 80 values of Me corresponding to the E values. I hope this helps.
 

1. How do I solve a single variable equation in Matlab?

To solve a single variable equation in Matlab, use the solve function. For example, to solve the equation x^2 + 3x - 7 = 0, you would write syms x to declare x as a symbolic variable, and then write solve(x^2 + 3x - 7 = 0, x). This will return the solutions to the equation.

2. Can I solve systems of equations in Matlab?

Yes, you can solve systems of equations in Matlab using the solve function as well. You will need to declare the variables as symbolic using the syms function, and then pass in the equations and variables to the solve function. Matlab will return the solutions to the system of equations.

3. How do I check if a solution to an equation is valid in Matlab?

To check if a solution to an equation is valid in Matlab, you can use the subs function. This function substitutes the solution into the equation and evaluates the result. If the result is equal to 0, then the solution is valid. If the result is not equal to 0, then the solution is not valid.

4. Can I solve equations with complex numbers in Matlab?

Yes, you can solve equations with complex numbers in Matlab. To do so, you will need to declare the variables as complex using the syms function, and then pass in the equations and variables to the solve function. Matlab will return the solutions, including any complex numbers, to the equation.

5. How do I plot the solutions to an equation in Matlab?

To plot the solutions to an equation in Matlab, first solve the equation using the solve function. Then, use the ezplot function to plot the equation with the solutions as the y-values. You can also use the hold on function to plot multiple solutions on the same plot.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
809
  • Advanced Physics Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
881
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
944
  • Engineering and Comp Sci Homework Help
Replies
2
Views
826
  • Advanced Physics Homework Help
Replies
4
Views
825
Replies
0
Views
682
  • Advanced Physics Homework Help
Replies
4
Views
440
Back
Top