How do I get a real, decimal answer from my equation instead of an empty array?

8 views (last 30 days)
Hi, I am struggling to get a real, decimal answer for the equation used below in my code. It keeps returning an empty array. Please let me know where I am going wrong. Thank you in advance.
% Parameters
syms x1
width = 1; % meters
nozzle = 0.05; % meters
cstress = 0.6 * 10^6; % Pa
force = 6.43 * 10^3; % N (converted over 1m width)
% Design criteria
crushing = force / cstress;
% Variable area
% Area 1
A1 = width * 2 * nozzle;
% Area 2 with variables
cent_height1 = x1-(7*nozzle/3);
angle1 = atan(cent_height1/(0.5*width))
angle1 = 
vertical_dist1 = nozzle/(cos(angle1));
A2 = (width/2)*(cent_height1+vertical_dist1);
A3 = 0.5*(width/2)*(cent_height1);
% Total Area
A = A1 + A2 - 2*(A3);
% Solve for x1
eqn1 = crushing == A
eqn1 = 
value1 = solve(eqn1, x1);
finalvalue1 = max(real(value1));
finalvalue1 = max(double(finalvalue1), 3*nozzle);
fprintf('x2: %.6f m \n', finalvalue1);
x2: m
  3 Comments
Dyuman Joshi
Dyuman Joshi on 21 Sep 2023
FYI - Wolfram Alpha also gives output as (no solutions exist) for eqn1.
643/60000 = sqrt((2*x-7/30)^2+1)/40 + 1/10
Alan Stevens
Alan Stevens on 21 Sep 2023
Plot the right-hand side of eqn1 against x1. You will see that its minimum value is larger than that of the left-hand side, hence no solution.

Sign in to comment.

Answers (1)

Nipun
Nipun on 25 Sep 2023
Hi Ruby,
I understand that you are trying to solve an equation using MATLAB solve functionality with no output.
On closely inspecting your input equations, I see that no solution exists for the system. The value of constant crushing as output by MATLAB:
0.0107
Additionally, if you plot A against x1, it has a minima at 7/60 with value 0.1250 . Hence, there is no intersection point for crushing and A. Therefore, no solution exists for eqn1
Hope this helps.
Regards,
Nipun

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!