solving for y in equation

3 views (last 30 days)
Kamil
Kamil on 9 Mar 2024
Edited: Torsten on 9 Mar 2024
I want to solve for y in following equation. It returns y with conditions. Next i want to plot using the calculated y as function definition, but i dont know how to do that. Here is my code:
syms x a h y v u
a = 85.147;
h = 55;
v = 50;
u = 25;
assume(x>=0)
x1 = 0:0.1:10;
eqn = x-sqrt(a^2+h^2)-(h-y)*cot(asin((h-y)/v))+(h-u)*cot(pi/4-asin((h-y)/v))+v*sin(asin((h-y)/v)) == 0
soly = isolate(eqn, y)
plot(x1,soly)

Answers (1)

Torsten
Torsten on 9 Mar 2024
Edited: Torsten on 9 Mar 2024
a = 85.147;
h = 55;
v = 50;
u = 25;
f = @(x,y)x-sqrt(a^2+h^2)-(h-y).*cot(asin((h-y)/v))+(h-u)*cot(pi/4-asin((h-y)/v))+v*sin(asin((h-y)/v))
f = function_handle with value:
@(x,y)x-sqrt(a^2+h^2)-(h-y).*cot(asin((h-y)/v))+(h-u)*cot(pi/4-asin((h-y)/v))+v*sin(asin((h-y)/v))
r = fimplicit(f,[-100 300 0 70])
r =
ImplicitFunctionLine with properties: Function: @(x,y)x-sqrt(a^2+h^2)-(h-y).*cot(asin((h-y)/v))+(h-u)*cot(pi/4-asin((h-y)/v))+v*sin(asin((h-y)/v)) XRange: [-100 300] YRange: [0 70] Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Use GET to show all properties
r.XData
ans = 1x445
300.0000 297.9229 297.3333 294.6667 292.0000 289.3333 286.6667 284.0000 281.3333 278.6667 276.1332 276.0000 273.3333 270.6667 268.0000 265.3333 262.6667 260.0000 257.6622 257.3333 254.6667 252.0000 249.3333 246.6667 244.0000 241.7386 241.3333 238.6667 236.0000 233.3333
r.YData
ans = 1x445
14.9703 14.9333 14.9207 14.8636 14.8065 14.7494 14.6923 14.6351 14.5780 14.5209 14.4667 14.4633 14.3959 14.3286 14.2612 14.1938 14.1264 14.0591 14.0000 13.9904 13.9122 13.8341 13.7559 13.6778 13.5996 13.5333 13.5198 13.4304 13.3411 13.2518
f(r.XData,r.YData)
ans = 1x445
0.1791 0 0.0523 0.2495 0.3839 0.4578 0.4731 0.4320 0.3364 0.1881 -0.0000 0.0108 0.1912 0.3059 0.3572 0.3475 0.2792 0.1543 -0.0000 0.0235 0.1753 0.2594 0.2786 0.2355 0.1325 0 0.0259 0.1552 0.2155 0.2098

Community Treasure Hunt

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

Start Hunting!