In MATLAB, I have an equation a*x+b=0 for which I have a and b defined during execution. What is the best way I can solve the equation using what I've set for a and b.
I guess that you are going to have to use num2str() and related functions to build the equation in the string form that solve() requires. That shouldn't be too difficult should it?
Can't you solve symbolically in terms of a and b, and then replace a and b by their value in the result?
Related
I have a symbolic matrix that depends on a complex parameter q. Let the matrix be A(q) and b a column vector. I would like to simultaneously solve the equations
A*b==0; b'*b==1;
using the solve command (preferably the numerical variant vpasolve). The variables to be found are both b and q. I am not quite sure about the syntax on how to do this and would appreciate any help on it. My main problem is that the equation is partially given in matrix form and the searched variable is a vector.
Do I have to resort to fsolve to achieve this? Or is there a way without defining a function?
The following definite integral can not be done in "Matlab R2013a", although it can be done analytically in other mathematics programs. Why?
syms r M c real
assume(M>0)
assume(c>M)
y=1/(sqrt((r^2-M)*(r^2/c^2-1))*r);
int(y,r,c,inf)
The answer is
atanh(sqrt(M)/c)/sqrt(M).
Thanks
There's another way to write the solution:
-log((-M-c^2+2*sqrt(M)*c)/(M-c^2))/(2*sqrt(M))
I don't use Matlab, but can you try assuming that M does not equal c^2?
I want to solve xA=b with constraint 0<=x for x.
I found functions like lsqnonneg and lsqlin which solves for Ax=b. However, couldn't find a good way to solve for xA=b.
How can I solve xA=b with non-negative x constraint?
As David commented, it is straightforward to show that
so you can use standard methods to solve the problem with A' and b' and then transpose the answer.
I am trying to use matlab's fsolve to solve a system of 4 nonlinear equations. I'm solving the system for each point in a grid of parameters by looping through each point and calling the fsolve function.
My problem is that I need to give some of these parameters as input to fsolve. These inputs should be treated as constants for each separate solving of the system.
Can anyone help me?
you can just do:
result = fsolve(#(x) eqns(a,b,c,d),guess)
and in addition make the function eqns() with your equation set.
I have a equation like this:
2^n * exp((-p*k*n*(k*n-(k+1)*2^t)))/((k+1)^2*2^(2*t+1))- 1=0.
I tried using the follwing code, but it gives me a warning that "Explicit solution could not be found".
syms n k t p positive;
S=solve(2^n * exp((-p*k*n*(k*n-(k+1)*2^t)))/((k+1)^2*2^(2*t+1))- 1,n,'IgnoreAnalyticConstraints', true);
S
Is there a way to solve the equation in terms on n?
Thanks in advance
Short answer: NO
MATLAB tries to find an "Explicit" solution, one in which variable n is expressed in terms of the other variables. In your case, the solution is "Implicit", meaning that variable n cannot be isolated and thus appears on both sides of the equation.
I used a different tool and here is what I got.
[e^((-k^2-k)np2^t+k^2n^2p)=2^(-2t+n-1)/(k^2+2*k+1)]
As you can see, n appears on both sides.
You might want to take a look at this post