Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

Setsuna Yuuki.
Setsuna Yuuki. il 11 Nov 2020
Modificato: Setsuna Yuuki. il 11 Nov 2020
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')

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by