如何从 Matlab 矩阵中提取一列?

How to extract one column from Matlab matrix?

我有以下代码:

N = 10;
params = cell(N-3,4);
step = 1;
for i = 3 : N-1
    
    % Calibrate the camera
    [cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, ...
        'EstimateSkew', false, 'EstimateTangentialDistortion', false, ...
        'NumRadialDistortionCoefficients', 2, 'WorldUnits', 'centimeters', ...
        'InitialIntrinsicMatrix', [], 'InitialRadialDistortion', [], ...
        'ImageSize', [mrows, ncols]);

    
   %disp(cameraParams.IntrinsicMatrix(1,1));
   %params = [params, cameraParams.IntrinsicMatrix(1,1)];
   params{step} = [cameraParams.IntrinsicMatrix(1,1),...
                      cameraParams.IntrinsicMatrix(2,2),...
                        cameraParams.PrincipalPoint(1),...
                        cameraParams.PrincipalPoint(2)];
                    
   disp(cell2mat(params(step)));
   %disp(cell2mat(cellfun(@(x)   params(:,1),'uniformoutput',false)));
   step = step +1;
   
end

我需要从“params”矩阵中提取每一列(从 1、4 开始)以绘制它们的值...我该怎么做?

当我尝试时:

T = cell2table(params,...
'VariableNames', {'fx', 'fy', 'u0', 'v0'});
disp(T);

我得到:

此处无需将 params 存储在元胞数组中。相反,只需将 params 初始化为包含 NaN 或零的数组。

然后为 params 中的 step 设置适当的行:

N = 10;
params = NaN(N-3,4); % or zeros(N-3,4);
step = 1;
for k = 3 : N-1
    params(step,:) = rand(1,4);
    step = step + 1;
end

T = array2table(params,'VariableNames', {'fx', 'fy', 'u0', 'v0'})

哪个会产生

>> T
T =
  7×4 table
       fx          fy         u0         v0   
    ________    ________    _______    _______
    0.015403    0.043024    0.16899    0.64912
     0.73172     0.64775    0.45092    0.54701
     0.29632     0.74469    0.18896    0.68678
     0.18351     0.36848    0.62562    0.78023
    0.081126     0.92939    0.77571    0.48679
     0.43586     0.44678    0.30635    0.50851
     0.51077     0.81763    0.79483    0.64432