Array as input for symbolic function
9 次查看(过去 30 天)
显示 更早的评论
this is an quation for the Mach number as a function of location and area ratio
so I create an array of area ratios and want to examine M
A_ratio = (0:1:100);
gamma = 1.4;
syms M
eq1 = A_ratio == ((gamma+1)/2)^((gamma+1)/(2*(gamma-1)))*((1+(gamma-1)/2*M^2)^((gamma+1)/(2*(gamma-1)))/M)
var = vpa(eq1)
double(var)
here the symbolic output of vpa looks correct (non-zero), but when I try to change back from symbolic to numeric array the result is all zeros. is double() the wrong command for this? I am referencing: https://www.mathworks.com/help/symbolic/conversion.html
is there a smarter way to do this?
0 个评论
采纳的回答
Torsten
2022-2-27
gamma = 1.4;
syms A_ratio M
eq1 = A_ratio == ((gamma+1)/2)^((gamma+1)/(2*(gamma-1)))*((1+(gamma-1)/2*M^2)^((gamma+1)/(2*(gamma-1)))/M);
sol = solve(eq1,M);
solnum = subs(sol,A_ratio,1) %e.g.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!