Solution is not unique because the system is rank-deficient | Solve Function | Syms Variable | Will be very helpful, if you can resolve this pleaseeee

6 views (last 30 days)
I have been trying to resolve this error by using multiple methods but I'm unable to, please help. I have attached the relevant code and the data base. The first part of the code is the one in which I'm trying to collect data, the rest three parts are the supportin functions.
load X
Result = zeros(105,6);
e = 0;
for i = 1:1:105
try
[K1,K2,K3,K4,K5,K6] = Lead_Time(X(i,1),X(i,2),X(i,3),X(i,4),X(i,5),X(i,6),X(i,7));
Result(i,1:6) = [K1,K2,K3,K4,K5,K6];
catch
e = e+1;
error1(e) = i;
end
end
Warning: Solution is not unique because the system is rank-deficient.
Warning: Solution is not unique because the system is rank-deficient.
Warning: Solution is not unique because the system is rank-deficient.
Warning: Solution is not unique because the system is rank-deficient.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
Warning: Unable to find explicit solution. For options, see help.
function [Y,Ft1,Ft2,Ft3,Ra2,Ra3] = Lead_Time(Ra1,CVa1,CVa2,CVa3,m1,m2,m3)
[Ra2,Ra3] = Arr_rt(m2,m3,Ra1,CVa1,CVa2,CVa3);
Ft1 = Wait_Time(m1,CVa1,0,0.0625,Ra1,0.4);
Ft2 = Wait_Time(m2,CVa2,0,0.02,Ra2+Ra1,0);
Ft3 = Wait_Time(m3,CVa3,1,0.002,Ra3,1.5);
Is = (Ra1*Ft1) + ((Ra2+Ra1)*Ft2) + (Ra3*Ft3);
Ft = max([Ft1,Ft2,Ft3]);
Y = Is*Ft;
end
function [Ra2,Ra3] = Arr_rt(m2,m3,Ra1,CVa1,CVa2,CVa3)
syms Ra
%CVa2 = CVa1;
%CVa3 = CVa1;
eqn1 = (Wait_Time(m3,CVa3,1,0.002,((Ra1/(Ra+Ra1))*(1/Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0))),1.5))*Ra == 1;
eqn2 = Ra < (m2/(0.05));
eqn3 = ((Ra1+Ra)*(Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0))) > ((Ra1*0.0675)/m3);
eqns = [eqn1 eqn2 eqn3];
Ra = solve(eqns,Ra,'Real',true);
%Ra = vpasolve(eqns,Ra);
Ra2= Ra;
Ra3 = 1/Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0);
Ra3 = (Ra1/(Ra1+Ra))*Ra3;
end
function [Ts] = Wait_Time(m,CVa,CVp,p,Ra,s)
global u pf
pf = ((p.*60) + s)/24;
u = Ra.*pf./m;
Tq = (((CVp^2)+(CVa^2))/2)*pf.*((u.^(sqrt(2*(m+1))-1))/(m*(1-u)));
Ts = Tq+pf;
end

Answers (1)

Walter Roberson
Walter Roberson on 29 Feb 2024
You are trying to solve three equations for one variable. Although two of the equations are inequalities, solve() simply gives up when asked to handle more equations than variables.
  1 Comment
Walter Roberson
Walter Roberson on 29 Feb 2024
You can solve the equality and then test whether the solution satisfies the inequalities
load X
Result = zeros(105,6);
e = 0;
for i = 1:1:105
try
[K1,K2,K3,K4,K5,K6] = Lead_Time(X(i,1),X(i,2),X(i,3),X(i,4),X(i,5),X(i,6),X(i,7));
Result(i,1:6) = [K1,K2,K3,K4,K5,K6];
catch ME
e = e+1;
error1(e) = i;
Result(i,1:6) = nan;
disp(ME.message)
end
end
got 1 real root: 14.1195 got 2 successful roots, using first of them
successes = 1x2
3.0873 7.8279
got 2 successful roots, using first of them
successes = 1x2
2.2182 6.3655
got 2 successful roots, using first of them
successes = 1x2
1.9661 11.4391
got 1 real root: 14.7415 got 2 successful roots, using first of them
successes = 1x2
0.7050 11.0455
got 1 real root: 14.8146 got 1 real root: 11.9619 got 1 real root: 14.6463 got 1 real root: 14.8119 got 1 real root: 14.5339 got 1 real root: 12.4249 got 1 real root: 14.7888 got 1 real root: 14.0293 got 1 real root: 11.7671 got 1 real root: 14.8092 got 1 real root: 9.17147 got 1 real root: 13.4684 got 1 real root: 14.7573 got 1 real root: 14.658 got 1 real root: 13.789 no real roots got 1 real root: 14.3359 got 1 real root: 14.7891 got 1 real root: 2.82625 got 1 real root: 12.1299 got 1 real root: 12.008 got 1 real root: 0.836696 got 1 real root: 14.7434 got 1 real root: 14.6567 got 1 real root: 2.84251 got 1 real root: 11.148 got 1 real root: 12.9546 got 1 real root: 14.7603 got 1 real root: 8.36913 got 1 real root: 7.05532 got 1 real root: 4.88555 got 1 real root: 6.70282 got 1 real root: 10.6088 got 1 real root: 8.61488 got 1 real root: 14.498 got 1 real root: 0.129474 got 1 real root: 14.8056 got 1 real root: 14.4895 got 1 real root: 14.8118 got 1 real root: 14.8147 got 1 real root: 14.7897 got 1 real root: 14.8147 got 1 real root: 14.7961 got 1 real root: 14.7863 got 1 real root: 14.7247 got 1 real root: 14.7372 got 1 real root: 14.7083 got 1 real root: 14.1614 got 1 real root: 14.7552 got 1 real root: 14.5729 got 1 real root: 14.1916 got 1 real root: 14.5513 got 1 real root: 12.1878 got 1 real root: 14.7323 got 1 real root: 14.1287 got 1 real root: 14.7406 got 1 real root: 14.3588 got 1 real root: 14.4787 got 1 real root: 14.7659 got 1 real root: 14.5139 got 1 real root: 14.6161 got 1 real root: 14.6884 got 1 real root: 14.4093 got 1 real root: 14.6047 got 1 real root: 14.5132 got 1 real root: 14.4439 got 1 real root: 14.7952 got 1 real root: 14.3491 got 1 real root: 14.7269 got 1 real root: 14.59 got 1 real root: 14.7222 got 1 real root: 14.4685 got 1 real root: 14.3511 got 1 real root: 14.5079 got 1 real root: 14.8069 got 1 real root: 14.6354 got 1 real root: 14.5572 got 1 real root: 14.4752 got 1 real root: 14.0311
function [Y,Ft1,Ft2,Ft3,Ra2,Ra3] = Lead_Time(Ra1,CVa1,CVa2,CVa3,m1,m2,m3)
[Ra2,Ra3] = Arr_rt(m2,m3,Ra1,CVa1,CVa2,CVa3);
Ft1 = Wait_Time(m1,CVa1,0,0.0625,Ra1,0.4);
Ft2 = Wait_Time(m2,CVa2,0,0.02,Ra2+Ra1,0);
Ft3 = Wait_Time(m3,CVa3,1,0.002,Ra3,1.5);
Is = (Ra1*Ft1) + ((Ra2+Ra1)*Ft2) + (Ra3*Ft3);
Ft = max([Ft1,Ft2,Ft3]);
Y = Is*Ft;
end
function [Ra2,Ra3] = Arr_rt(m2,m3,Ra1,CVa1,CVa2,CVa3)
syms Ra
%CVa2 = CVa1;
%CVa3 = CVa1;
eqn1 = (Wait_Time(m3,CVa3,1,0.002,((Ra1/(Ra+Ra1))*(1/Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0))),1.5))*Ra == 1;
eqn2 = Ra < (m2/(0.05));
eqn3 = ((Ra1+Ra)*(Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0))) > ((Ra1*0.0675)/m3);
eqns = [eqn1 eqn2 eqn3];
Rasol = vpasolve(eqns(1),Ra); % solve(eqns(1),Ra,'Real',true);
Rasol = Rasol(imag(Rasol) == 0);
if isempty(Rasol)
Ra2 = sym(nan);
Ra3 = sym(nan);
fprintf('no real roots\n');
else
successes = [];
for Ra_ = Rasol(:).'
test = vpa(subs(eqns(2:end), Ra, Ra_));
if all(isAlways(test, Unknown="false"))
successes(end+1) = Ra_;
end
end
if isempty(successes)
Ra2 = sym(nan);
Ra3 = sym(nan);
else
if length(successes) > 1
fprintf('got %d successful roots, using first of them\n', length(successes));
successes
else
fprintf('got 1 real root: %g\n', successes);
end
Ra = successes(1);
Ra2 = Ra;
Ra3 = 1/Wait_Time(m2,CVa2,0,0.02,Ra+Ra1,0);
Ra3 = (Ra1/(Ra1+Ra))*Ra3;
end
end
end
function [Ts] = Wait_Time(m,CVa,CVp,p,Ra,s)
global u pf
pf = ((p.*60) + s)/24;
u = Ra.*pf./m;
Tq = (((CVp^2)+(CVa^2))/2)*pf.*((u.^(sqrt(2*(m+1))-1))/(m*(1-u)));
Ts = Tq+pf;
end

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!