【问题标题】:Limit the range of least square regression限制最小二乘回归的范围
【发布时间】:2017-08-02 12:47:40
【问题描述】:

我想对一组数据 A(k1,k2) 进行回归,但是我想将回归限制在 -K1<k1<K1-K2<k<K2 的范围内。 A是由60x60矩阵组成的图像相位,维度为MxN。从A 的归一化频率区域的中心以 0.1N/2 进行最小二乘逼近。

以下是部分代码:

A=rand(60);
[m, n]=size(A);
[M,N] = meshgrid(1:m,1:n);
X = [M(:), N(:)];
B=regress(A(:), X);  %regression will be done on all the values of A, part where adjustment needed
hat=reshape(X*B,m,n);

【问题讨论】:

    标签: matlab regression least-squares


    【解决方案1】:

    您可以先选择要对其执行回归的矩阵子集:

    % generate the full image
    A_full=rand(60);
    [m, n]=size(A_full);
    
    % select the part you want, 
    % it is not very clear to me if this is really the part you want, 
    % but I think you will be able to change it to your needs
    A=A_full(floor(m/2-0.1*m/2):ceil(m/2+0.1*m/2), floor(n/2-0.1*n/2):ceil(n/2+0.1*n/2)); 
    
    % perform the regression on the selected part of A (like you did it)
    [m, n]=size(A);
    [M,N] = meshgrid(1:m,1:n);
    X = [M(:), N(:)];
    B=regress(A(:), X);  %regression will be done on all the values of A, part where adjustment needed
    hat=reshape(X*B,m,n);
    

    【讨论】:

    • 出于好奇,是否可以让所有k2 值为零,同时保持所有k1A(k1,0)
    • 是的,只要定义AA=A_full(floor(m/2-0.1*m/2):ceil(m/2+0.1*m/2),floor(n/2));我假设k2=0对应矩阵的中间,可能不是这样。 (matlab中不存在索引0)
    猜你喜欢
    • 2015-05-15
    • 2015-10-31
    • 1970-01-01
    • 2015-09-16
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-28
    相关资源
    最近更新 更多