【问题标题】:Erroneous case/rep labeling in MATLAB FDA plot_fit plot titlesMATLAB FDA plot_fit 图标题中的错误案例/代表标签
【发布时间】:2015-09-11 08:39:34
【问题描述】:

我正在使用Jim Ramsay's FDA package for MATLAB 对我通过实验获得的数据进行功能分析。我正在为我的功能数据对象设置标签,生成它,并使用以下代码绘制它:

% Set up labels

fdnames = cell(1,3);
fdnames{1} = 'Time (ms)';
cnd = cell(1,2);
cnd{1} = 'Condition';
cnd{2} = ['C1'; 'C2'; 'C3'];
fdnames{2} = cnd;
fdnames{3} = 'Values';

% Generate functional data object from
% arguments (t), data (y), basis object (bss),
% default value for derivative order (4), lambda (0.1),
% and labels (fdnames)

fdObj = data2fd(t, y, bss, 4, 0.1, fdnames);

% Plot

plot_fit(y, t, fdObj);

这会产生 3 个图。它们三个的标签中都有“C1”,而不是“C1”、“C2”和“C3”,它们是我在我的功能对象中为案例/复制提供的标签。

我想用正确的标签来绘制我的功能对象。感谢更有经验的 MATLAB 和 FDA 用户的任何帮助。

【问题讨论】:

    标签: matlab plot


    【解决方案1】:

    这是由于 FDA 软件包中的 plot_fit 函数中的错误造成的。以下是该函数的部分代码:

    % ...
    casenames = fdnames{2};
    % ...
    %  plot the results
    if residual
      %  plot the residuals
      ylimit = [min(min(min(res))), max(max(max(res)))];
        for i = 1:nrep 
            for j = 1:nvar
                % ...
                if nrep > 1
                    if iscell(casenames)
                        title(['\fontsize{12} ', casenames{2}(j,:), ...
                            '  RMS residual = ',num2str(sqrt(MSE(j,i)))])
                    else
                        title(['\fontsize{12} Case ', num2str(i), ...
                            '  RMS residual = ',num2str(sqrt(MSE(j,i)))])
                    end
                else
                   % ...
                end
            end
            pause
       end
     else
      %  plot the data and fit
      % ...
        for i = 1:nrep 
            for j = 1:nvar
              % ...
                if nrep > 1
                    if iscell(casenames)
                        title(['\fontsize{12} ', casenames{2}(j,:), ...
                            '  RMS residual = ',num2str(sqrt(MSE(j,i)))])
                    else
                        title(['\fontsize{12} Case ', num2str(i), ...
                            '  RMS residual = ',num2str(sqrt(MSE(j,i)))])
                    end
                  % ...
    

    在这里,虽然变量 ij 分别迭代案例/代表和变量,但行

    title(['\fontsize{12} ', casenames{2}(j,:), ...
    

    使用j 作为参数来选择哪个案例/代表名称将出现在标题中。更新包以替换此行

    title(['\fontsize{12} ', casenames{2}(i,:), ...
    

    可以解决问题。

    【讨论】:

    • 我已经联系了 FDA 软件包的开发人员,他们确认了这个错误和这个解决方案。因此,我接受这个答案。
    猜你喜欢
    • 1970-01-01
    • 2015-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多