Getting Complex numbers for a (2equation+2unknown)

1 view (last 30 days)
Hi All
I am wondering why I am getting complex numbers for this code, any help would be really appreciated.
clear
clc
close all
syms sigma a
a0=0.01;
w=0.05;
% defining the equations
F=0.265*(1-(a/w))^4 +(0.857+0.265*(a/w))*((1-(a/w))^(-3/2));
Kapp=sigma*sqrt(3.14*a)*F;
KC=110000000;
KR=KC*(4-3*exp(-(a-a0)/0.003));
diffKapp = diff(Kapp,a)
diffKR = diff(KR,a)
%solving the equations
[S, avalue] = solve([Kapp == KR, diffKapp == diffKR], [sigma, a])
double(S)
double (avalue)

Accepted Answer

Philip Caplan
Philip Caplan on 29 Apr 2015
You can ensure 'sigma' and 'a' are treated as real variables by declaring them slightly differently. Instead of
syms sigma a
please use
sigma = sym('sigma','real');
a = sym('a','real');
For more information on setting assumptions for symbolic variables, please see
  1 Comment
Sia
Sia on 29 Apr 2015
Thanks man, the problem is my equations were not linear and I had to use iteration to solve it ;)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!