我正在尝试运行多元线性回归,然后将beta放入矩阵中。但是,我不确定如何使用矢量操作而不是使用for或仅手动输入它。
是否可以对以下示例进行矢量化?
% Data input as per the assignment.
cro = (0.5:0.5:2.5) * 10^(-4)
cro_350 = [0.166, 0.342, 0.493, 0.671, 0.836]
cro_410 = [0.037, 0.056, 0.087, 0.115, 0.145]
cr = [1:5] * 10^(-2)
cr_350 = [0.125, 0.263, 0.394, 0.522, 0.646]
cr_410 = [0.227, 0.459, 0.691, 0.922, 1.141]
% Performing the regressions on Cr2O7.
cro_m1 = fitlm(cro, cro_350)
cro_m2 = fitlm(cro, cro_410)
% Performing the regressions on Cr.
cr_m1 = fitlm(cr, cr_350)
cr_m2 = fitlm(cr, cr_410)
K = [cro_m1.Coefficients.Estimate(2), cro_m2.Coefficients.Estimate(2);
cr_m1.Coefficients.Estimate(2), cr_m2.Coefficients.Estimate(2)]
所以,我的问题是:我可以在不使用for循环的情况下以编程方式构造矩阵K(针对性能问题)吗?