![](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?
1 回表示 (過去 30 日間)
古いコメントを表示
Gabrielle Bartolome
2020 年 11 月 11 日
編集済み: Setsuna Yuuki.
2020 年 11 月 11 日
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 件のコメント
採用された回答
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/410255/image.jpeg)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!