Creating a chart of T v. P. How do I use the solve function to solve every part of an array?

1 次查看(过去 30 天)
I am trying to design a chart of T v. P (torsion v. tension) for a given D(diameter) and a specific n factor of safety) at various values of Sy. The equation that I am using is (sy/(2*n))^2 = ((2*P)/(pi*D^2))^2 + ((16*T)/(pi*D^3))^2
n = 2;
D = 8.35;
start = 10;
finish =200;
sy = 64;
T = linspace(start, finish, 200);
syms P;
eqn = ((2*P)/(pi*D^2))^2 +((16*T)/(pi*D^3)).^2-(sy/(2*n))^2
P = solve(eqn, P) %eqn produces an array but it is in a bunch of equations whcih I need to solve. But it doesn't work or put it in an array.
tensionValues = eval(P)
plot(T, tensionValues)
eqn =
P =
Empty sym: 0-by-1
tensionValues =
[]
Error using plot
Vectors must be the same length.
Error in ideasCase1 (line 21)
plot(T, tensionValues)

采纳的回答

Setsuna Yuuki.
Setsuna Yuuki. 2020-11-11
编辑:Setsuna Yuuki. 2020-11-11
you need use solve() element to element.
n = 2; D = 8.35; start = 10; finish =200;
sy = 64; T = linspace(start, finish, 200);
syms P;
tensionValues = zeros(1,length(T));
eqn = ((2*P)/(pi*D^2))^2 +((16*T)/(pi*D^3)).^2-(sy/(2*n))^2;
for i = 1:length(T)
p = solve(eqn(i), P); %eqn(1:200)
tensionValues(i) = eval(p(1)); %has two solution, the other solution is p(2)
end
plot(T, tensionValues')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by