I'm trying to solve a system of nonlinear equations for which I have more unknowns than equations. I have conditions for a few of the variables to limit the number of solutions. And I would also like to output the solutions into an easily visually parseable table of numeric values where all values are aligned to their respective solutions.
What I have to begin with is the code below. This is giving me a parameterized solution warning, though. Assuming I haven't made a syntax mistake this should produce a solution. I have tested a solution by explicitly declaring variables within the bounds I've set to confirm this. For example, if:
V_as = 275f_s = 140
then without conditions MATLAB would return:
C_ms = 836e-6BL = 3.41Q_ms = 3.8M_md = 1.48e-3
Maybe just setting these boundaries still isn't constraining it enough? Should I try specifically declaring an array of values for f_s and V_as? Would that help? And how would I go about doing that?
Also, I would like to output all these variables into a table of numeric values aligned to each solution but I'm not sure how to do that since they're stored in a symbolic cell array. Something like:
output_table = [double(sol.BL), double(sol.M_md), double(Q_ms), etc...]
And how to make sure that each variable in a particular row is from the same solution as the variable next to it in the same row? And how to set the columns to have headers representing each variable?
syms f_s V_as M_ms Q_es Q_ms C_ms M_md BL;D = 4.4e-2;S_d = pi*(D/2)^2;SPL = 85;Q_ts = 0.35;R_e = 3.3;assume(in(f_s/10,'integer') & f_s>=100 & f_s<=150);assume(in(V_as/25,'integer') & V_as>=100 & V_as<=1000);assume(M_md>=1e-3 & M_md<5e-3);assume(BL>3 & BL<3.5);assume(C_ms>0 & C_ms<1500e-6);assume(Q_ms>0 & Q_ms<10);e1 = f_s == 1/(2*pi*sqrt(M_ms*C_ms));e2 = Q_es == R_e/BL^2*sqrt(M_ms/C_ms);e3 = Q_ts == Q_ms*Q_es/(Q_ms+Q_es);e4 = V_as*10^-6 == 1.21*343^2*S_d^2*C_ms;e5 = M_ms == S_d^2*(M_md/S_d^2+2*8*1.21/(3*pi^2*(D/2)));e6 = SPL == 20*log10(1.21*BL*S_d*sqrt(R_e)/(2*pi*R_e*M_ms*2e-5));sol = solve(e1,e2,e3,e4,e5,e6,f_s,V_as,Q_es,Q_ms,M_ms,M_md,BL,C_ms);
Best Answer