怎么查看matlab函数的源代码_matlab源代码怎么用

怎么查看matlab函数的源代码_matlab源代码怎么用如何查看MATLAB函数的源代码   大家都知道MATLAB是开源的,所有的函数源代码都是可以查看的。但是,对于初学者来说,可能还不知道如何查看MATLAB函数的源代码。函数之  type   假设需要查看function_name的源代码,在命令窗口中键入 type  function_name  即:>>typeimreadfunction[X,map,alp

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

如何查看MATLAB函数的源代码

   大家都知道MATLAB是开源的,所有的函数源代码都是可以查看的。但是,对于初学者来说,可能还不知道如何查看MATLAB函数的源代码。

函数之  type

   假设需要查看function_name的源代码,在命令窗口中键入 type  function_name  

即:

>> type imread

function [X, map, alpha] = imread(varargin)
%IMREAD Read image from graphics file.
%   A = IMREAD(FILENAME,FMT) reads a grayscale or color image from the file
%   specified by the string FILENAME. If the file is not in the current
%   directory, or in a directory on the MATLAB path, specify the full
%   pathname.
%  
%   The text string FMT specifies the format of the file by its standard
%   file extension. For example, specify ‘gif’ for Graphics Interchange
%   Format files. To see a list of supported formats, with their file
%   extensions, use the IMFORMATS function. If IMREAD cannot find a file
%   named FILENAME, it looks for a file named FILENAME.FMT.
%
%   The return value A is an array containing the image data. If the file
%   contains a grayscale image, A is an M-by-N array. If the file contains
%   a truecolor image, A is an M-by-N-by-3 array. For TIFF files containing
%   color images that use the CMYK color space, A is an M-by-N-by-4 array.
%   See TIFF in the Format-Specific Information section for more
%   information.
%  
%   The class of A depends on the bits-per-sample of the image data,
%   rounded to the next byte boundary. For example, IMREAD returns 24-bit
%   color data as an array of uint8 data because the sample size for each
%   color component is 8 bits. See the Remarks section for a discussion of 
%   bitdepths, and see the Format-Specific Information section for more 
%   detail about supported bitdepths and sample sizes for a particular
%   format.
%   
%   [X,MAP] = IMREAD(FILENAME,FMT) reads the indexed image in FILENAME into
%   X and its associated colormap into MAP. Colormap values in the image
%   file are automatically rescaled into the range [0,1].
%
%   […] = IMREAD(FILENAME) attempts to infer the format of the file
%   from its content.
%
%   […] = IMREAD(URL,…) reads the image from an Internet URL. 
%   
%   Remarks
%   
%   Bitdepth is the number of bits used to represent each image pixel. 
%   Bitdepth is calculated by multiplying the bits-per-sample with the
%   samples-per-pixel. Thus, a format that uses 8-bits for each color
%   component (or sample) and three samples per pixel has a bitdepth of 24.
%   Sometimes the sample size associated with a bitdepth can be ambiguous:
%   does a 48-bit bitdepth represent six 8-bit samples or three 16-bit
%   samples? The following format-specific sections provide sample size
%   information to avoid this ambiguity.
%   
%   Format-Specific Information (Listed Alphabetically by Format)
%  
%   BMP  —  Windows Bitmap
%
%   Supported  Compression     Output  
%   Bitdepths  None    RLE     Class    Notes
%   ———————————————————
%    1-bit      x        –     logical 
%    4-bit      x        x     uint8         
%    8-bit      x        x     uint8
%   16-bit      x        –     uint8    1 sample/pixel
%   24-bit      x        –     uint8    3 samples/pixel
%   32-bit      x        –     uint8    3 samples/pixel (1 byte padding)
%      
%   CUR  — Cursor File

%   Supported    Compression      Output
%   Bitdepths   None Compressed   Class 
%   ————————————————–
%   1-bit        x      –         logical
%   4-bit        x      –         uint8         
%   8-bit        x      –         uint8
%  
%   Special syntaxes:
%  
%   […] = IMREAD(…,IDX) reads in one image from a multi-image icon or
%   cursor file. IDX is an integer value that specifies the order that the
%   image appears in the file. For example, if IDX is 3, IMREAD reads the
%   third image in the file. If you omit this argument, IMREAD reads the
%   first image in the file.
%
%   [A,MAP,ALPHA] = IMREAD(…) returns the AND mask for the resource,
%   which can be used to determine transparency information.  For cursor
%   files, this mask may contain the only useful data.   
%    
%   GIF  —  Graphics Interchange Format
%  
%   Supported     Compression        Output
%   Bitdepths    None  Compressed    Class 
%   ———————————————
%   1-bit         x        –         logical
%   2-to-8 bit    x        –         uint8  
%  
%   Special syntaxes:
%  
%   […] = IMREAD(…,IDX) reads in one or more frames from a multiframe
%   (i.e., animated) GIF file. IDX must be an integer scalar or vector of
%   integer values.  For example, if IDX is 3, IMREAD reads the third image
%   in the file.  If IDX is 1:5, only the first five frames are returned.
%
%   […] = IMREAD(…,’Frames’,IDX) is the same as the syntax above except
%   that IDX can be ‘all’.  In this case, all of the frames are read and
%   returned in the order that they appear in the file.
%
%   Note: Because of the way GIF files are structured, all of the frames
%   must be read when a particular frame is requested. Consequently, it is
%   much faster to specify a vector of frames or ‘all’ for IDX than to call
%   IMREAD in a loop when reading multiple frames from the same GIF file.
%  
%   HDF  —  Hierarchical Data Format
%    
%   Supported   Raster image   Raster image     Output
%   Bitdepths   with colormap  without colormap Class    Notes
%   ————————————————————
%    8-bit        x               x             uint8
%   24-bit        –               x             uint8   3 samples/pixel
%  
%   Special Syntaxes:
%  
%   […] = IMREAD(…,REF) reads in one image from a multi-image HDF file.
%   REF is an integer value that specifies the reference number used to
%   identify the image. For example, if REF is 12, IMREAD reads the image
%   whose reference number is 12. (Note that in an HDF file the reference
%   numbers do not necessarily correspond with the order of the images in
%   the file. You can use IMFINFO to match up image order with reference
%   number.) If you omit this argument, IMREAD reads the first image in
%   the file.
%    
%   ICO  — Icon File
%  
%   See CUR.
%  
%   JPEG  —  Joint Photographic Experts Group
%  
%   Note: IMREAD can read any baseline JPEG image as well as JPEG images
%   with some commonly used extensions.
%  
%   Supported    Compression      Output
%   Bitdepths   Lossy Lossless    Class      Notes
%   ——————————————————–
%    8-bit        x      x        uint8     Grayscale or RGB
%   12-bit        x      x        uint16    Grayscale 
%   16-bit        –      x        uint16    Grayscale
%   36-bit        x      x        uint16    RGB(Three 12-bit samples/pixel)
%
%   JPEG 2000 – Joint Photographic Experts Group 2000
%
%   Supported      Compression      Output
%   Bitdepths     Lossy Lossless    Class  
%   (per sample)
%   ———————————————————-
%    1-bit          x      x        logical
%    2- to 8-bit    x      x        uint8
%    9- to 16-bit   x      x        uint16
%
%   Note: Indexed JPEG 2000 images are not supported. Only JP2 compatible
%   color spaces are supported for JP2/JPX files. Arbitrary channels are
%   supported for raw codestream J2C files.
%
%   Special Syntaxes
%
%   […] = IMREAD(…, ‘Param1’, value1, ‘Param2’, value2, …) uses
%   parameter-value pairs to control the read operation. 
%
%       Parameter name   Value
%       ————–   —–
%       ‘ReductionLevel’ A non-negative integer specifying reduction in 
%                        the resolution of the image. For a reduction
%                        level ‘L’, the image resolution is reduced by a
%                        factor of 2^L. Its default value is 0 implying
%                        no reduction. The reduction level is limited by
%                        the total number of decomposition levels as 
%                        provided by ‘WaveletDecompositionLevels’ field 
%                        in the structure returned from IMFINFO function.  
%
%       ‘PixelRegion’    {ROWS, COLS}.  IMREAD returns the sub-image
%                        specified by the boundaries in ROWS and COLS.
%                        ROWS and COLS must both be two-element vectors
%                        that denote the 1-based indices [START STOP]. If
%                        ‘ReductionLevel’ is greater than 0, then ROWS and
%                        COLS are coordinates in the reduced-sized image.  
%
%       ‘V79Compatible’  A BOOL value. If true, image returned is color
%                        converted to gray-scale or RGB image as consistent
%                        with previous versions of IMREAD (MATLAB 7.9
%                        [R2009b] and earlier). Otherwise raw color
%                        image is returned. Default is false.
%
%
%   PBM  —  Portable Bitmap
%  
%   Supported  Raw     ASCII (Plain)  Output
%   Bitdepths  Binary  Encoded        Class
%   —————————————-
%   1-bit        x        x          logical
%     
%   PCX  —  Windows Paintbrush

%   Supported     Output   
%   Bitdepths     Class       Notes
%   ———————————————-
%    1-bit        logical     Grayscale only
%    8-bit        uint8       Grayscale or indexed
%   24-bit        uint8       RGB (8-bit samples)
%   
%   PGM  —  Portable Graymap
%       
%   Supported        Raw      ASCII (Plain)  Output       
%   Bitdepths        Binary   Encoded        Class
%   ————————————————
%   up to 16-bit      x            –         uint8
%   Arbitrary         –            x
%   
%   PNG  —  Portable Network Graphics
%  
%   Supported     Output   
%   Bitdepths     Class      Notes
%   ——————————————-
%    1-bit        logical    Grayscale only
%    2-bit        uint8      Grayscale only
%    4-bit        uint8      Grayscale only
%    8-bit        uint8      Grayscale or Indexed
%   16-bit        uint16     Grayscale or Indexed
%   24-bit        uint8      RGB (Three 8-bit samples/pixel)
%   48-bit        uint16     RGB (Three 16-bit samples/pixel)
%        
%   Special Syntaxes:
%  
%   […] = IMREAD(…,’BackgroundColor’,BG) composites any transparent
%   pixels in the input image against the color specified in BG.  If BG is
%   ‘none’, then no compositing is performed. Otherwise, if the input image
%   is indexed, BG should be an integer in the range [1,P] where P is the
%   colormap length. If the input image is grayscale, BG should be an
%   integer in the range [0,1].  If the input image is RGB, BG should be a
%   three-element vector whose values are in the range [0,1]. The string
%   ‘BackgroundColor’ may be abbreviated. 
%
%   If the ALPHA output argument is used (see below), then BG defaults to
%   ‘none’ if not specified by the user. Otherwise, if the PNG file
%   ontains a background color chunk, that color is used as the default 
%   value for BG. If ALPHA is not used and the file does not contain a
%   background color chunk, then the default value for BG is 1 for indexed 
%   images; 0 for grayscale images; and [0 0 0] for RGB images. 
%
%   [A,MAP,ALPHA] = IMREAD(…) returns the alpha channel if one is
%   present; otherwise ALPHA is []. If ‘BackgroundColor’ is specified by
%   the user then ALPHA is []. Note that MAP may be empty if the file
%   contains a grayscale or truecolor image.   
%    
%   PPM  —  Portable Pixmap
%  
%   Supported        Raw      ASCII (Plain)  Output       
%   Bitdepths        Binary   Encoded        Class
%   ————————————————
%   up to 16-bit      x            –         uint8
%   Arbitrary         –            x    
%  
%   RAS  —  Sun Raster
%  
%   Supported    Output   
%   Bitdepths    Class     Notes
%   —————————————————-
%    1-bit       logical   Bitmap 
%    8-bit       uint8     Indexed
%   24-bit       uint8     RGB (8-bit samples)
%   32-bit       uint8     RGB with Alpha (8-bit samples)
%   
%   TIFF  —  Tagged Image File Format
%  
%   Supported     Compression                             Output    
%   Bitdepths None Packbits CCITT RGB ICCLAB CIELAB CMYK Class    Notes
%   ———————————————————————–
%    1-bit     x      x       x    –    –      –     –   logical 
%    8-bit     x      x       –    –    –      –     –   uint8
%   12-bit     –      –       –    –    –      –     –   uint16  Grayscale
%                                                                or Indexed
%   16-bit     –      –       –    –    –      –     –   uint16  Grayscale
%                                                                or Indexed
%   24-bit     x      x       –    x    x      x     –   uint8   3 samples
%   32-bit     –      –       –    –    –      –     x   uint8   4 samples
%   36-bit     –      –       –    x    –      –     –   uint16  3 samples
%   48-bit     –      –       –    x    x      x     –   uint16  3 samples     
%   64-bit     –      –       –    –    –      –     x   double  4 samples
%  
%   NOTE: IMREAD supports 8-bit integral and 32-bit floating point tiled
%   TIFF images, with any compression and colorspace combination listed
%   above, and 32-bit IEEE floating point images.
%  
%   Special Syntaxes:
%  
%   A = IMREAD(…) returns color data that uses the RGB, CIELAB, ICCLAB,
%   or CMYK color spaces.  If the color image uses the CMYK color space, A
%   is an M-by-N-by-4 array.
%
%   […] = IMREAD(…, ‘Param1’, value1, ‘Param2’, value2, …) uses
%   parameter-value pairs to control the read operation.  There are three
%   different parameters you can use:
%
%       Parameter name   Value
%       ————–   —–
%       ‘Index’          A positive integer specifying which image to read in
%                        a multi-image TIFF file.  For example, if ‘Index’ is
%                        3, IMREAD reads the third image in the file.
%
%       ‘Info’           A structure array; the output of IMFINFO.  When
%                        reading images from a multi-image TIFF file, passing
%                        the output of IMFINFO as the ‘Info’ parameter helps
%                        IMREAD locate the images in the file more quickly.
%
%       ‘PixelRegion’    {ROWS, COLS}.  IMREAD returns the sub-image
%                        specified by the boundaries in ROWS and COLS.  ROWS
%                        and COLS must be either two- or three-element
%                        vectors.  If two elements are provided, they denote
%                        the 1-based indices [START STOP].  If three elements
%                        are provided, the indices [START INCREMENT STOP]
%                        allow image downsampling.
%  
%   XWD  —  X Window Dump
%  
%   Supported                                  Output   
%   Bitdepths  ZPixmaps  XYBitmaps  XYPixmaps  Class
%   ————————————————–
%   1-bit        x          –         x        logical
%   8-bit        x          –         –        uint8
%
%   Please read the file libtiffcopyright.txt for more information.
%
%   Example:
%
%       imdata = imread(‘ngc6543a.jpg’);
%
%   See also IMFINFO, IMWRITE, IMFORMATS, FREAD, IMAGE, DOUBLE, UINT8.

%   Copyright 1984-2011 The MathWorks, Inc.
%   $Revision: 1.1.6.22.4.1 $  $Date: 2012/07/02 18:58:54 $

[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});

% Download remote file.
if (strfind(filename, ‘://’))
 
    url = true;
 
    if (~usejava(‘jvm’))
        error(message(‘MATLAB:imagesci:imread:noJava’))
    end
   
    try
        filename = urlwrite(filename, tempname);
    catch %#ok<*CTCH>
        error(message(‘MATLAB:imagesci:imread:readURL’, filename));
    end
   
else
 
    url = false;

end

if (isempty(fmt_s))
    % The format was not specified explicitly.
   
    % Verify that the file exists.
    fid = fopen(filename, ‘r’);
    if (fid == -1)
     
        if ~isempty(dir(filename))
            error(message(‘MATLAB:imagesci:imread:fileReadPermission’, filename));
        else
            error(message(‘MATLAB:imagesci:imread:fileDoesNotExist’, filename));
        end

    else
        % File exists.  Get full filename.
        filename = fopen(fid);
        fclose(fid);
    end
   
    % Try to determine the file type.
    [format, fmt_s] = imftype(filename);

    if (isempty(format))
        error(message(‘MATLAB:imagesci:imread:fileFormat’));
    end
   
else
    % The format was specified explicitly.
   
    % Verify that the file exists.
    fid = fopen(filename, ‘r’);
    if (fid == -1)
        % Couldn’t open using the given filename; search for a
        % file with an appropriate extension.
        for p = 1:length(fmt_s.ext)
            fid = fopen([filename ‘.’ fmt_s.ext{p}]);
           
            if (fid ~= -1)
                % The file was found.  Don’t continue searching.
                break
            end
        end
    end
   
    if (fid == -1)
        if ~isempty(dir(filename))
            error(message(‘MATLAB:imagesci:imread:fileReadPermission’, filename));
        else
            error(message(‘MATLAB:imagesci:imread:fileDoesNotExist’, filename));
        end
    else
        filename = fopen(fid);
        fclose(fid);
    end
   
end

if isempty(fmt_s)
    % Get format details.
    fmt_s = imformats(format);
end

% Verify that a read function exists
if (isempty(fmt_s.read))
    error(message(‘MATLAB:imagesci:imread:readFunctionRegistration’, fmt_s.ext{ 1 }));
end

if ((fmt_s.alpha) && (nargout == 3))
 
    % Use the alpha channel.
    [X, map, alpha] = feval(fmt_s.read, filename, extraArgs{:});
   
else

    % Alpha channel is not requested or is not applicable.
    alpha = [];
    [X, map] = feval(fmt_s.read, filename, extraArgs{:});
   
end

% Delete temporary file from Internet download.
if (url)
    delete_download(filename);
end

 

%————————————————————————–
function delete_download(filename)

try
    delete(filename);
catch
    warning(message(‘MATLAB:imagesci:imread:tempFileDelete’, filename))
end

     

%————————————————————————–
function [filename, fmt_s, extraArgs] = parse_inputs(varargin)

filename = ”;
fmt_s = struct([]);
extraArgs = {};

% Parse arguments based on their number.
switch(nargin)
case 0

    % Not allowed.
    error(message(‘MATLAB:imagesci:imread:inputParsing’));
   
case 1

    % Filename only.
    filename = varargin{1};
    if ~ischar(filename)
        error(message(‘MATLAB:imagesci:imread:badImageSourceDatatype’));
    end
   
otherwise

    % Filename and format or other arguments.
    filename = varargin{1};
   
    % Check whether second argument is a format.
    if (ischar(varargin{2}))
        fmt_s = imformats(varargin{2});
    end
   
    if (~isempty(fmt_s))
        % The argument matches a format.
        extraArgs = varargin(3:end);
    else
        % The argument begins the format-specific parameters.
        extraArgs = varargin(2:end);
    end
   
end

>>

 

 

 

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/186035.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 基于51单片机的多功能八路抢答器[通俗易懂]

    基于51单片机的多功能八路抢答器[通俗易懂]1.功能介绍多功能八路抢答器是基于51单片机来设计的,除了可以实现最基本功能——8路抢答外,还具有自动处理犯规选手,抢答时间调整,还可以进行答题,计分,并且可以查询或修改分数。2.硬件设计该抢答器的硬件由五个部分组成,包括单片机、按键电路、数码管显示电路、指示灯电路和声音提示电路。硬件框图如下(2)硬件原理图由于每个部分的硬件电路都比较简单,就不做介绍了,大家直接看图。3.软件设…

    2022年10月20日
  • 2000数据库置疑怎么处理_msdb数据库置疑的解决方法

    2000数据库置疑怎么处理_msdb数据库置疑的解决方法由于服务器意外的断电,导致SQLSERVER服务器上数据库出现“置疑”而无法使用,通过网上搜索,找到以下方法解决问题,这里记录一下:产生数据库置疑的时侯,数据库文件和日志文件都是存在的,如果数据库文件都不存在了,则要另当处理。1、停止数据库服务器,将数据库MDF文件和LDF文件复制备份一份2、启动数据库服务器,删除置疑的数据库3、仅用备份的数据库MDF文件附加数据库,sp_attach_…

  • pycharm加注释的快捷方式_pycharm如何批量注释

    pycharm加注释的快捷方式_pycharm如何批量注释1、主题  在开发项目的过程中经常需要创建任务列表,对于一些小任务,在代码中插入便签注释会有奇效。  这种注释的格式如下:  2、创建便签注释  非常简单:  首先,将光标定位到相应行。  然后,创建一行注释(Ctrl+Slash)。  最后,在#后面,输入TODO或者todo,然后输入注释  3、浏览便签  在T

  • datagrip最新激活码【在线破解激活】

    datagrip最新激活码【在线破解激活】,https://javaforall.cn/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

  • ThinkPHP实现定时执行任务的两种方法「建议收藏」

    ThinkPHP实现定时执行任务的两种方法「建议收藏」在平常的项目中我们总是会遇到需要将某个方法任务定时执行的问题,定时执行方法任务如果我们拥有服务器的权限,我们可以直接在服务器设置定时任务,例如在Windows的任务计划程序中进行设置,在Linux中编写脚本进行执行。如果我们没有服务器权限,我们该如何使用项目的程序代码来自动定时执行呢?接下来就为大家描述一个基于ThinkPHP框架定时执行任务的例子,具体的方法会在下面进行详细的描述。   

  • linux禁止防火墙命令,LINUX关闭打开防火墙命令

    Linux下打开和关闭防火墙1.及时生效,重启后复原关闭:serviceiptablesstop开启:serviceiptalbesstart查看状态:serviceiptablesstatus(关闭状态的话会提示firewalisnotrunning)2.非及时性生效,重启后永久性生效关闭:chkconfigiptbalesoff开启:chkconfigipt…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号