![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/410255/image.jpeg)
Creating a chart of T v. P. How do I use the solve function to solve every part of an array?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gabrielle Bartolome
am 11 Nov. 2020
Bearbeitet: Setsuna Yuuki.
am 11 Nov. 2020
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)
0 Kommentare
Akzeptierte Antwort
Setsuna Yuuki.
am 11 Nov. 2020
Bearbeitet: Setsuna Yuuki.
am 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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/410255/image.jpeg)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!