从单元格转换为逻辑不可能出错

时间:2013-12-05 06:54:24

标签: matlab matlab-figure

我在MATLAB中有一个函数如下:

function varargout = test_M(varargin)

         I = imread('c:\test.bmp');
         imshow(I); (works fine)

         I = imread(varargin);     % Conversion to logical from cell is not possible error
         imshow(I);

         char a;
         a = varargin;

         disp(a);                 % prints 'c:\test.bmp' on command window
         disp(varargin);          % prints 'c:\test.bmp' on command window

         I = imread(a);   % Conversion to logical from cell is not possible error
         imshow(I);

我从命令窗口运行文件,如下所示

    test_M('c:\test.bmp'); 

我在标题中遇到错误:

  

无法从单元格转换为逻辑

为什么imread('c:\test.bmp')有效但imread(varargin)imread(a)没有?

1 个答案:

答案 0 :(得分:0)

要打开varargin并将其转发到varargin{:}的其他功能, 在你的情况下是imread(varargin{:})