Afaf
Afaf

Reputation: 59

solve equation using MATLAB solve

I have the following equation that I want to solve using MATLAB:

enter image description here

X is the unknown variable. I am trying to solve it using MATLAB solve, but I find it hard to code the left part of the equation.

Is it possible to use solve? Are there any other options?

EDIT

Since A and B depends respectively on j and i I have tried to put them in vectors as follows:

A = [A(1) ... A(j) ... A(N)]
B = [B(1) ... B(i) ... B(N)]

I was trying to have something that looks like this:

eqn = sum(A ./ sum(B .* D)) == C;
solve(eqn);

but the whole difficulty is in this part:

enter image description here

because it depends on both i and j.

Upvotes: 0

Views: 380

Answers (1)

jualsevi
jualsevi

Reputation: 289

To write equation you can use this code:

syms x real
C = 1;
beta = 10;
alph = 0.5;

N = 10;
lenA = N;
lenB = N;

A = rand(1,N);
B = rand(1,N);

eq = 0;
for j=2:N
    eqaux = 0;
    for i=1:N
        eqaux = eqaux+B(i)/((alph+beta*x)^(i+j+1));
    end
    eq = eq+A(j)/eqaux;
end
eq = simplify(eq==C);

If x must be a complex number, delete real of syms x real.

To solve the equation use this code:

sol = solve(eq,x);
sol = vpa(sol);

Of course yu must use your own values of C, alph, beta, A, B and N.

Upvotes: 1

Related Questions