MATLAB 运行报错 'Matrix must be square.' 的解决方法
clc;clear all; syms x y z n eq1 = x + ny - nz*(30/60) == 0; % 一个检票窗口情况下的方程 eq2 = x + 2ny - 2nz*(10/60) == 0; % 两个检票窗口情况下的方程 eq3 = x + ny - 4n*z == 0; % 4分钟内所有旅客检票完毕的方程 det_eq = det([coeffs(eq1, [x y z]); coeffs(eq2, [x y z]); coeffs(eq3, [x y z])]); % 方程组系数行列式 if symvar(det_eq) == [n] % 判断方程组系数行列式是否只包含n这个未知数 solve(det_eq == 0, n) % 求解方程组系数行列式为0的n的值,即需要开放的检票窗口数 else disp('Error: Matrix must be square.') end
原文地址: https://www.cveoy.top/t/topic/oHbD 著作权归作者所有。请勿转载和采集!