필터 지우기
필터 지우기

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