matlab 函数源代码(求MATLAB里imread这个函数的源代码)

本文目录
- 求MATLAB里imread这个函数的源代码
- matlab让别人运行程序但看不到源代码
- matlab中conv(卷积)函数的C语言实现的源代码请求大虾帮助
- 要怎么看Matlab自带函数的源代码
- MATLAB里bd_asymp函数源代码是什么
求MATLAB里imread这个函数的源代码
function = imread(varargin)
= parse_inputs(varargin{:});
if (~isempty(msg))
error(’MATLAB:imread:inputParsing’, ’%s’, msg);
end
% Download remote file.
if (strfind(filename, ’://’))
url = true;
if (~usejava(’mwt’))
error(’MATLAB:imread:noJava’, ’Reading from a URL requires a Java Virtual Machine.’)
end
try
filename = urlwrite(filename, tempname);
catch
error(’MATLAB:imread:readURL’, ’Can’’t read URL "%s".’, filename);
end
else
url = false;
end
if (isempty(format))
% The format was not specified explicitly.
% Verify that the file exists.
fid = fopen(filename, ’r’);
if (fid == -1)
if ~isempty(dir(filename))
error(’MATLAB:imread:fileOpen’, [’Can’’t open file "%s" for reading;\nyou’ ...
’ may not have read permission.’], ...
filename);
else
error(’MATLAB:imread:fileOpen’, ’File "%s" does not exist.’, filename);
end
else
% File exists. Get full filename.
filename = fopen(fid);
fclose(fid);
end
% Try to determine the file type.
format = imftype(filename);
if (isempty(format))
error(’MATLAB:imread:fileFormat’, ’Unable to determine the file format.’);
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.
fmt_s = imformats(format);
if (isempty(fmt_s))
error(’MATLAB:imread:fileFormat’, [’Couldn’’t find format %s in the format registry.’ ...
’ See "help imformats".’], format);
end
for p = 1:length(fmt_s.ext)
fid = fopen();
if (fid ~= -1)
% The file was found. Don’t continue searching.
break
end
end
end
if (fid == -1)
if ~isempty(dir(filename))
error(’MATLAB:imread:fileOpen’, [’Can’’t open file "%s" for reading;\nyou’ ...
’ may not have read permission.’], ...
filename);
else
error(’MATLAB:imread:fileOpen’, ’File "%s" does not exist.’, filename);
end
else
filename = fopen(fid);
fclose(fid);
end
end
% Get format details.
fmt_s = imformats(format);
% Verify that a read function exists
if (isempty(fmt_s.read))
error(’MATLAB:imread:readFunctionRegistration’, ’No reading function for format %s. See "help imformats".’, ...
fmt_s.ext{1});
end
if ((fmt_s.alpha) && (nargout == 3))
% Use the alpha channel.
= feval(fmt_s.read, filename, extraArgs{:});
else
% Alpha channel is not requested or is not applicable.
alpha = ;
= feval(fmt_s.read, filename, extraArgs{:});
end
% Delete temporary file from Internet download.
if (url)
delete_download(filename);
end
%%%
%%% Function delete_download
%%%
function delete_download(filename)
try
delete(filename);
catch
warning(’MATLAB:imread:tempFileDelete’, ’Can’’t delete temporary file "%s".’, filename)
end
%%%
%%% Function parse_inputs
%%%
function = ...
parse_inputs(varargin)
filename = ’’;
format = ’’;
extraArgs = {};
msg = ’’;
% Parse arguments based on their number.
switch(nargin)
case 0
% Not allowed.
msg = ’Too few input arguments.’;
return;
case 1
% Filename only.
filename = varargin{1};
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});
else
fmt_s = struct();
end
if (~isempty(fmt_s))
% The argument matches a format.
format = varargin{2};
extraArgs = varargin(3:end);
else
% The argument begins the format-specific parameters.
extraArgs = varargin(2:end);
end
end
matlab让别人运行程序但看不到源代码
1、在命令窗口中输入:type 函数名(例如type rgb2gray等),就会在命令窗口出现该函数的相关说明及源代码;
2、在命令窗口中输入:open 函数名(例如open rgb2gray等),就会打开该函数的m文件;
3、在命令窗口中输入:edit函数名(例如edit rgb2gray等),同样会打开该函数的m文件;
4、还有一种方法就是故意将原函数的参数类型或者个数写错,就会出现出错提示,点击提示出错处,也可以打开该函数的m文件;很多大型的函数都能获得源代码,但是MATLAB里面有一些built-in函数是看不到源代码的,sort就是其中之一。这些函数是预编译好的,运行效率非常好,比如像find、min、max等频繁用到的一些函数还有很多矩阵运算函数都是built-in函数。自带函数,用type+函数名。比如,type dwt2可以显示dwt2函数的代码但是,好像没有qpsk这个函数.
matlab中conv(卷积)函数的C语言实现的源代码请求大虾帮助
function a=myconv(b,c)
bs=size(b);
cs=size(c);
i=any(bs-cs);
if i
error(’error’)
end
i=any(~(bs-1));
if ~i
error(’error’)
end
ko=0;
if bs(1)》bs(2)
b=b’;
c=c’;
ko=1;
end
bs=size(b);
cs=size(c);
ss=2*bs(2)-1;
a=zeros(1,ss);
for i=1:cs(2)
q=zeros(1,i-1);
p=zeros(1,ss-cs(2)+1-i);
ba=;
ma=b(i)*ba;
a=a+ma;
end
if ko
a=a’;
end
end
测试了一下,跟conv计算的结果偏差很小(我测试的结果是10^-15左右),执行效率略低(用cputime 测试rand(1,99),差了0.2964) 商业软件就是牛啊 真想知matlab中这个函数的源代码
要怎么看Matlab自带函数的源代码
MATALB属于半开源软件,其中很多函数可以通过“open/edit/type+filename”命令进行和查看源代码。但是有一些函数仅仅可以找到它的帮助文档,却无法看到具体的源代码,比如min,fft,sum等函数,因为这些函数属于MATLAB的built-in function(内置函数),即MATLAB的built-in
function的代码是不公开的,有人说这些函数的算法是最优化的,保证较低的时间复杂度提高效率,所以,我感觉写一个算法优先考虑调用MATLAB自带函数,自带函数解决不了的情况下,再自己去写,毕竟自己写的代码的效率无法达到最优。
MATLAB里bd_asymp函数源代码是什么
具体函数如下所示,
function =bd_asymp(G,w)
G1=zpk(G); Gtf=tf(G);
if nargin==1,
w=freqint2(Gtf.num{1},Gtf.den{1},100);
end
zer=G1.z{1}; pol=G1.p{1}; gain=G1.k;
wpos=;
for i=1:length(zer);
if isreal(zer(i))
wpos=;
pos1=;
else
if imag(zer(i))》0
wpos=;
pos1=;
end, end, end
for i=1:length(pol);
if isreal(pol(i))
wpos=;
pos1=;
else
if imag(pol(i))》0
wpos=;
pos1=;
end, end, end
wpos=;
pos1=;
=sort(wpos); pos1=pos1(ii);
ii=find(abs(wpos)《eps); kslp=0;
w_start=1000*eps;
if length(ii)》0,
kslp=sum(pos1(ii));
ii=(ii(length(ii))+1):length(wpos);
wpos=wpos(ii); pos1=pos1(ii);
end
while 1
=bode(G,w_start);
if isinf(ypos1), w_start=w_start*10;
else, break; end
end
wpos=;
ypos(1)=20*log10(ypos1);
pos1=;
for i=2:length(wpos)
kslp=sum(pos1(1:i-1));
ypos(i)=ypos(i-1)+...
kslp*log10(wpos(i)/wpos(i-1));
end
ii=find(wpos》=w(1)&wpos《=w(length(w)));
wpos=wpos(ii); ypos=ypos(ii);

更多文章:
centos7安装apache服务(您好,想请教下怎么在 linux(centos 7)中配置安装apache服务器)
2026年1月31日 12:30
clips怎么读?用eclipse开发安卓APP,弄好在哪里打包或签名apk
2025年10月16日 13:30
php兼职招聘(2021福建厦门同安区丙州幼儿园编外教师招聘公告)
2026年5月5日 01:45
喵艺术|04 春天不会迟到——大卫霍克尼?如何评价大卫·霍克尼
2025年9月28日 07:30
python中range的用法和作用(Python内置函数range)
2025年9月13日 00:00
html5框架代码写在哪里(在html页面上编写javascript代码时应编写在什么标)
2026年2月11日 14:15
word通配符大全(请问在word或者wps中使用通配符时,要表达“或者”这个条件时使用什么符号)
2026年6月9日 05:00
floatleft是什么意思(float:left 与display:inline的具体区别)
2025年8月7日 19:00















