Solve equation without using symbolic toolbox in Matlab - matlab

I need to solve this equation for the variable \theta:
using Matlab WITHOUT using symbolic toolbox. The reason for this is that I am compiling the m-file to .Net Assembly and symbolic toolbox can not be used.
I know how to solve it using vpasolve, but as far as I know it needs the variable to be defined using syms.
I appreciate if you can suggest me a method to solve this equation in Matlab without symbolic toolbox.

As #rayryeng said, that is only possible if you know the value of the other variables, is so, you can declare f as an anonymous function and use fsolve() like this:
f=#(x)((cos(x)*sqrt(2^2+3^2)-4*sin(x))/(cos(x)-1)-5/x);
fsolve(f,0.1)
but using your correct values.

Related

Simbiology toolbox and fmincon in MATLAB

Is is possible to use the model simulated in the Simbiology toolbox of Matlab
to be used to implement fmincon for the same by calling the model from Simbiology?
It is possible to simulate the SimBiology model from a MATLAB script or the command line (see sbiosimulate). This allows the simulation results to be used by any other MATLAB function as needed. I assume that in your case you want to use the simulation results to construct an objective function to use with fmincon and it is possible. Let me know if you need more details.
The short answer is probably, yes. If you have access to the tools and try this, let me know and we can help further.

What is actually symbolic variable in matlab?

I am new in learning matlab. when I am using the solve() function, matlab warning me that i must use a symbolic variable before using the solve function. but I actually don't know what the sym variable is. or What is the difference between the symbolic variables and the ordinary variables of the base workspace?
Symbolic variables are useful to express equations and manipulate them in an analytic manner. You can use them to manipulte them algebrically, without the need of actually associating any type of numbers.
Suppose you want the exact analytical form of a solution for an equation, in terms of symbols that express this function. Then you can use a sym variable to express and operate with the unkwons, rather than to use on numerical methods to find solutions
Symbolic variables are also useful to operate with tranfer funcions and perform simplications that are very tedious If done without a computer program.
You also can associate numbers with sym variables, once you have done all the all the intended operations.
If you don't want perform operations with algebraic variables, you should checkout the fsolve function

How to use integer and binary variables with matlab GA toolbox?

I used matlab GA toolbox to solve an integer programming problem. The problem has some binary variables.
I used nonlinear constraints such as x*(1-x) = 0 for binary variables, but matlab outputs real values for these variables.
One another problem is that final solution is not feasible! I used this line of code:
options = gaoptimset(options,'CreationFcn', #gacreationlinearfeasible);
But matlab still generating no feasible solutions.
A friend suggested using inequality constraints instead of equality ones, but that failed.
Then there is two problems. 1) say matlab about binary variables, 2) generating feasible solutions.
How can I use matlab GA for my problem?
I'm not sure it is best solution, but I solved my problem by substitute constraints for penalty coefficients in fitness function.
After all, as a suggestion, anyone who has same problem can try GAlib (C++ genetic library) instead of matlab.

Is 'ols' function in Econometrics toolbox in MATLAB?

I am trying to run a code which calls the function OLS. reg=ols(y,X). I am getting an error saying that ols is an undefined function for input of type double. Is ols a function in the econometrics toolbox or do we create a separate ols function? I have checked the working directory and the toolbox is added to the path. I don't know what the problem is.
I don't have ols either and I have the econometrics toolbox. I'm guessing you are looking for some functions in File Exchange, most likely the Toolkit on Econometrics and Economics Teaching.

How can I implicitly solve a single equation in Matlab?

The following equation is to be solved for M by MATLAB:
(Atemp/At)^2=1/M^2*((2/(gamma+1))*(1+(gamma-1)*M^2/2))^((gamma+1)/(gamma-1))
It is not possible to solve this equation symbolically. In Maple it is easily possible to solve such an equation implicitly; now, is there also a pre-made function in Matlab that does this for me? I could program one myself, but as my skills are limited, its performance would not fit my needs.
I would try using fzero, or if that encounters problems because of complex values/infinities, fminbnd.