After doing little research I found out that it is not a problem of algebra, actually it is a problem of simple for loop problem. Here is how I solved it:
function compaction_values=fdd(lower,higher)
%FDD Field dry density.
% FDD(lower,higher) prints all combinations of values of A,B,C,D,E,
% F,G,H,L,M and Field Compaction accordingly, where field compaction's
% highest value is equal to input argument 'higher' and field compaction's
% lowest value is equal to input argument 'lower'.
%
% Note: The values of inputs 'lower' and 'higher' should be nonnegative
% real numbers. Negative values will print an error message.
if nargin ~= 2
error('Number of inputs must be two.');
elseif ~isscalar(lower) || ~isscalar(higher) || lower<0 || higher<0 || isempty(lower) || isempty(higher)
error('Inputs must be nonnegative scalars.');
else
A = 2860;
C = 34620;
S = 2.160;
Q = 1.349;
count = 0;
compaction_values=[];
for B = 6000:20:7100
for D = 27440:20:28180
for L = 5:-0.1:4.5
E = C-D;
F = E-A;
G = F/Q;
H = B/G;
M = (H/(L+100))*100;
compaction = (M/S)*100;
if compaction >=lower && compaction <= higher %This statement forces the function to print only needed values.
fprintf('%.0f %.0f %.0f %.0f %.0f %.0f %.0f %.2f %.1f %.2f %.2f\n',A,B,C,D,E,F,G,H,L,M,compaction);
compaction_values=[compaction_values;A,B,C,D,E,F,G,H,L,M,compaction];
count = count+1; %Counts the number of combinations.
end
end
end
end
fprintf('\ncount=%d\n',count);
end
end
You might have noticed some chages in data from the actual question but it's the same type of question.