如何查看matlab自带函数源代码

2024-05-04 15:50

1. 如何查看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自带函数源代码

2. 大家的matlab源代码都从哪儿找的

http://www.mathworks.cn/matlabcentral/fileexchange/

3. matlab源代码是什么样子的

一般来说,较大型的软件,通常都是由若干种语言和开发技术共同完成的。他们的开发也是由多个小组分别使用不同技术开发不同的组件,最后组合而成。

他的大多数文件使用 VC++ 书写,你可以看到他的安装包包含 vcredist_x86,这是典型的VC++的运行时库。

另外,matlab 还使用了 Perl,Python 等开发语言或技术。当然还有 Java。你也可以在安装目录发现类似的支持文件,例如 JavaAccessBridge.dll

甚至不止是桌面程序,matlab 还使用了很多浏览器和服务器端的开发工具和架构。

最后,还有一大堆的工具箱,是 matlab 自身脚本书写的。

如果你想看某个函数的脚本,可以在命令窗中输入:edit 函数名 ,再按回车。

matlab源代码是什么样子的

4. matlab 源代码

clear all;

m=1; %转子质量
r=57e-3;%轴颈半径 
c=0.2e-3;%轴承半径间隙 
yt=18e-3 ;%润滑油黏度 
L=28.5e-3;%轴瓦宽度
%  kp=1.052e8;c1=4000;c2=9000;
w=1000;%转速
e=0.06e-3;%质量偏心
g=9.8;%重力加速度
D=2*r;%轴颈直径
fai=c/r;%间隙比
pi=3.14159265;
%%%%%%%%%%%%%%无量纲化
G=g/(c*w^2);%无量纲g
P=e/c;%无量纲质量偏心率
MM=(m*c*w*fai^2)/(yt*L*r);%无量纲质量
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%x=zeros(2,1);
%x1=zeros(2,1);
%x2=zeros(2,1);
%x0=[0.8,0.8,0.8,0.8]';
%dt=pi/100;

u=[-0.8638,0.2512]';%位移初始值
v=[-0.2039,-0.7229]';%速度初始值
a=[0,0]';%加速度初始值
%t(1)=0;               %时间
x(:,1)=u;             %位移
x1(:,1)=v;            %速度
x2(:,1)=a;            %加速度


 
%M=zeros(2);
%K=zeros(2);
%C=zeros(2);
%Q=zeros(2,1);
%F=zeros(2,1);
M=[MM,0;
    0,MM];


%newmark参数设置
gamma=0.5;
dt=pi/100;
delta=0.25;
a0=1/(delta*dt^2);
a1=gama/(delta*dt);
a2=1/(delta*dt);
a3=1/(2*delta)-1;
a4=gamma/delta-1;
a5=dt*(gamma/(2*delta)-1);
a6=dt*(1-gamma);
a7=gamma*dt; 
%等效刚度矩阵
Ke=K+a0*M+a1*C;
t_max=1*pi;       %计算时间总长
i=1;
t(1)=0;
%q=zeros(2,1);
%fid1=fopen('weiyi.dat','wt');
while t(i)<t_max 
 %%%%%%广义力设定
%Qx=w^2*ww*ee*cos(t(i));
%Qy=w^2*ww*ee*sin(t(i));%此时不考虑重力
tao=w*t(i);%无量纲时间
Qx=MM*P*sin(tao);
Qy=MM*P*cos(tao)+MM*G;
Q=[Qx,Qy]';
%Q(i)=[MM*P*sin(tao(i)),MM*P*cos(tao(i))+MM*G]';
arf=atan((x1(1,i)+2*x(2,i))/(x(1,i)-2*x1(2,i)))-pi/2*sign((x1(1,i)+2*x(2,i))/(x(1,i)-2*x1(2,i)))-pi/2*sign(x1(1,i)+2*x(2,i));
Ga=2/sqrt(1-x(1,i)^2-x1(1,i)^2)*(pi/2+atan((x1(1,i)*cos(arf)-x(1,i)*sin(arf))/sqrt(1-x(1,i)^2-x1(1,i)^2)));
Va=(2+(x1(1,i)*cos(arf)-x(1,i)*sin(arf))*Ga)/(1-x(1,i)^2-x1(1,i)^2);
Sa=(x(1,i)*cos(arf)+x1(1,i)*sin(arf))/(1-(x(1,i)*cos(arf)+x1(1,i)*sin(arf))^2);
f11=-sqrt((x(1,i)-2*x1(2,i))^2+(x1(1,i)+2*x(2,i))^2)/(1-x(1,i)^2-x1(1,i)^2);
f12=3*x(1,i)*Va-Ga*sin(arf)-2*cos(arf)*Sa;
f22=3*x1(1,i)*Va+Ga*cos(arf)-2*sin(arf)*Sa;
 fx=f11*f12;
 fy=f11*f22;
Fx=-fx;
Fy=-fy;
F=[Fx,Fy]';
    %%%%%%%%%%%%%%%%%%%%%
    %Q=[0 0 fx 0 0 0 0 0 fy 0 0 0]';
      q(:,i+1)=F+Q+M*(a0*x(:,i)+a2*x1(:,i)+a3*x2(:,i))+C*(a1*x(:,i)+a4*x1(:,i)+a5*x2(:,i)); 
      x(:,i+1)=inv(Ke)*q(:,i+1);
      x2(:,i+1)=a0*(x(:,i+1)-x(:,i))-a2*x1(:,i)-a3*x2(:,i);
%       x1(i,i+1)=a1*(x(i,i+1)-x(i,i))-a4*x1(i,i)-a5*x2(i,i);
      x1(:,i+1)=x1(:,i)+a6*x2(:,i)+a7*x2(:,i+1);
%       fprintf(fid1,'%5d %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e %15.6e\n',i,x(i,i+1));
  plot(t(i),x(1,i),'k*');
%       plot(t,x1(1,i),'ro');
%       hold on;
% plot(t,x2(1,i),'go');
% hold on;
      i=i+1;
      t(i)=t(i-1)+dt;
 %       plot(t(i),x(1,i));
  end
 %   figure(1) 
  %plot(t(:),x(1,:),'k*');   
  %  plot(t(i),x(1,i));
      
  %  figure(2)
  %  plot(t,x(7,i));
  %  figure(3)
  %  plot(x(1,i),x(7,i));
  %   hold on;
% fclose(fid1);
哪位高手帮忙写下每步什么意思 
yishshibuzhidao

5. 怎么查matlab源代码

简单点的方法:在命令窗口输入:函数名
回车
即会提示该函数的出错,点击带有下划线的红色的函数名,即弹出该函数的源代码!

怎么查matlab源代码

6. matlab放音乐的源代码

% Cripple Pachebel's Canon on Matlab
% Have fun

fs = 44100; % sample rate
dt = 1/fs;

T16 = 0.125;

t16 = [0:dt:T16];
[temp k] = size(t16);

t4 = linspace(0,4*T16,4*k);
t8 = linspace(0,2*T16,2*k);

[temp i] = size(t4);
[temp j] = size(t8);

% Modification functions
mod4 = sin(pi*t4/t4(end));
mod8 = sin(pi*t8/t8(end));
mod16 = sin(pi*t16/t16(end));

f0 = 2*146.8; % reference frequency

ScaleTable = [2/3 3/4 5/6 15/16 ...
              1 9/8 5/4 4/3 3/2 5/3 9/5 15/8 ...
              2 9/4 5/2 8/3 3 10/3 15/4 4 ...
              1/2 9/16 5/8];
% 1/4 notes
do0f = mod4.*cos(2*pi*ScaleTable(21)*f0*t4);
re0f = mod4.*cos(2*pi*ScaleTable(22)*f0*t4);
mi0f = mod4.*cos(2*pi*ScaleTable(23)*f0*t4);
          
fa0f = mod4.*cos(2*pi*ScaleTable(1)*f0*t4);
so0f = mod4.*cos(2*pi*ScaleTable(2)*f0*t4);
la0f = mod4.*cos(2*pi*ScaleTable(3)*f0*t4);
ti0f = mod4.*cos(2*pi*ScaleTable(4)*f0*t4);
do1f = mod4.*cos(2*pi*ScaleTable(5)*f0*t4);
re1f = mod4.*cos(2*pi*ScaleTable(6)*f0*t4);
mi1f = mod4.*cos(2*pi*ScaleTable(7)*f0*t4);
fa1f = mod4.*cos(2*pi*ScaleTable(8)*f0*t4);
so1f = mod4.*cos(2*pi*ScaleTable(9)*f0*t4);
la1f = mod4.*cos(2*pi*ScaleTable(10)*f0*t4);
tb1f = mod4.*cos(2*pi*ScaleTable(11)*f0*t4);
ti1f = mod4.*cos(2*pi*ScaleTable(12)*f0*t4);
do2f = mod4.*cos(2*pi*ScaleTable(13)*f0*t4);
re2f = mod4.*cos(2*pi*ScaleTable(14)*f0*t4);
mi2f = mod4.*cos(2*pi*ScaleTable(15)*f0*t4);
fa2f = mod4.*cos(2*pi*ScaleTable(16)*f0*t4);
so2f = mod4.*cos(2*pi*ScaleTable(17)*f0*t4);
la2f = mod4.*cos(2*pi*ScaleTable(18)*f0*t4);
ti2f = mod4.*cos(2*pi*ScaleTable(19)*f0*t4);
do3f = mod4.*cos(2*pi*ScaleTable(20)*f0*t4);
blkf = zeros(1,i);

% 1/8 notes
fa0e = mod8.*cos(2*pi*ScaleTable(1)*f0*t8);
so0e = mod8.*cos(2*pi*ScaleTable(2)*f0*t8);
la0e = mod8.*cos(2*pi*ScaleTable(3)*f0*t8);
ti0e = mod8.*cos(2*pi*ScaleTable(4)*f0*t8);
do1e = mod8.*cos(2*pi*ScaleTable(5)*f0*t8);
re1e = mod8.*cos(2*pi*ScaleTable(6)*f0*t8);
mi1e = mod8.*cos(2*pi*ScaleTable(7)*f0*t8);
fa1e = mod8.*cos(2*pi*ScaleTable(8)*f0*t8);
so1e = mod8.*cos(2*pi*ScaleTable(9)*f0*t8);
la1e = mod8.*cos(2*pi*ScaleTable(10)*f0*t8);
tb1e = mod8.*cos(2*pi*ScaleTable(11)*f0*t8);
ti1e = mod8.*cos(2*pi*ScaleTable(12)*f0*t8);
do2e = mod8.*cos(2*pi*ScaleTable(13)*f0*t8);
re2e = mod8.*cos(2*pi*ScaleTable(14)*f0*t8);
mi2e = mod8.*cos(2*pi*ScaleTable(15)*f0*t8);
fa2e = mod8.*cos(2*pi*ScaleTable(16)*f0*t8);
so2e = mod8.*cos(2*pi*ScaleTable(17)*f0*t8);
la2e = mod8.*cos(2*pi*ScaleTable(18)*f0*t8);
ti2e = mod8.*cos(2*pi*ScaleTable(19)*f0*t8);
do3e = mod8.*cos(2*pi*ScaleTable(20)*f0*t8);
blke = zeros(1,j);

% 1/16 notes
fa0s = mod16.*cos(2*pi*ScaleTable(1)*f0*t16);
so0s = mod16.*cos(2*pi*ScaleTable(2)*f0*t16);
la0s = mod16.*cos(2*pi*ScaleTable(3)*f0*t16);
ti0s = mod16.*cos(2*pi*ScaleTable(4)*f0*t16);
do1s = mod16.*cos(2*pi*ScaleTable(5)*f0*t16);
re1s = mod16.*cos(2*pi*ScaleTable(6)*f0*t16);
mi1s = mod16.*cos(2*pi*ScaleTable(7)*f0*t16);
fa1s = mod16.*cos(2*pi*ScaleTable(8)*f0*t16);
so1s = mod16.*cos(2*pi*ScaleTable(9)*f0*t16);
la1s = mod16.*cos(2*pi*ScaleTable(10)*f0*t16);
tb1s = mod16.*cos(2*pi*ScaleTable(11)*f0*t16);
ti1s = mod16.*cos(2*pi*ScaleTable(12)*f0*t16);
do2s = mod16.*cos(2*pi*ScaleTable(13)*f0*t16);
re2s = mod16.*cos(2*pi*ScaleTable(14)*f0*t16);
mi2s = mod16.*cos(2*pi*ScaleTable(15)*f0*t16);
fa2s = mod16.*cos(2*pi*ScaleTable(16)*f0*t16);
so2s = mod16.*cos(2*pi*ScaleTable(17)*f0*t16);
la2s = mod16.*cos(2*pi*ScaleTable(18)*f0*t16);
ti2s = mod16.*cos(2*pi*ScaleTable(19)*f0*t16);
do3s = mod16.*cos(2*pi*ScaleTable(20)*f0*t16);
blks = zeros(1,k);

% Blank Block
blkblock = [blkf blkf blkf blkf  blkf blkf blkf blkf...
            blkf blkf blkf blkf  blkf blkf blkf blkf];

% Base Melody
cello = [do1f do1f so0f so0f  la0f la0f mi0f mi0f...
         fa0f fa0f do0f do0f  fa0f fa0f so0f so0f];

% So-FUCKING-Long Melody     
violin = [mi2f mi2f re2f re2f  do2f do2f ti1f ti1f...
          la1f la1f so1f so1f  la1f la1f ti1f ti1f ...%
          do2f do2f ti1f ti1f  la1f la1f so1f so1f...
          fa1f fa1f mi1f mi1f  fa1f fa1f re1f re1f ...%
          do1f mi1f so1f fa1f  mi1f do1f mi1f re1f...
          do1f la0f do1f so1f  fa1f la1f so1f fa1f...%
          mi1f do1f re1f ti1f  do2f mi2f so2f so1f...
          la1f fa1f so1f mi1f  do1f do2f blkf blke ti1e ...%
          do2e ti1e do2e do1e  ti0e so1e re1e mi1e...
          do1e do2e ti1e la1e  ti1e mi2e so2e la2e...
          fa2e mi2e re2e fa2e  mi2e re2e do2e ti1e...
          la1e so1e fa1e mi1e  re1e fa1e mi1e re1e... %%
          do1e re1e mi1e fa1e  so1e re1e so1e fa1e...
          mi1e la1e so1e fa1e  so1e fa1e mi1e re1e...
          do1e la0e la1e ti1e  do2e ti1e la1e so1e...
          fa1e mi1e re1e la1e  so1e la1e so1e fa1e...%
          mi1f mi2e blke re2f re2f  blkf do1f mi2f mi2f...
          la2f la2f so2f so2f  la2f la2f ti2f ti2f...%
          do3e blke do2e blke ti1f ti1f  blkf la1f do2f do2f...
          do2f do2f do2f do2f  do2f fa2f re2f so2f...%
          so2e mi2s fa2s so2e mi2s fa2s so2s so1s la1s ti1s ...
          do2s re2s mi2s fa2s mi2e do2s re2s...
          mi2e mi1s fa1s so1s la1s so1s fa1s so1s mi1s fa1s so1s...
          fa1e la1s so1s fa1e mi1s re1s mi1s re1s do1s re1s mi1s fa1s so1s la1s...
          fa2e la1s so1s la1e ti1s do2s so1s la1s ti1s do2s re2s mi2s fa2s so2s...%
          mi2e do2s re2s mi2e re2s do2s re2s ti1s do2s re2s mi2s re2s do2s ti1s...
          do2e la1s ti1s do2e do1s re1s mi1s fa1s mi1s re1s mi1s do2s ti1s do2s...
          la1e do2s ti1s la1e so1s fa1s so1s fa1s mi1s fa1s so1s la1s ti1s do2s...
          la2e do2s ti1s do2e ti1s la1s ti1s do2s re2s do2s ti1s do1s la1s ti1s...%%
          do2e blke blkf ti1e blke blkf la1e blke blkf do2e blke blkf...
          do1e blke blkf do1e blke blkf do1e blke blkf do1e blke blkf...%
          blkf so1e blke blkf so1e blke blkf mi1e blke blkf so1e blke...
          blkf fa1e blke blkf mi1e blke blkf fa1e blke blkf re2e blke...%
          mi2e mi1e fa1e mi1e re1e re2e mi2e re2e do2e mi1e do1e do2e ti1e so0e fa0e so0e...
          la0e la1e so1e la1e so1e so0e fa0e so0e do1e la1e so1e la1e ti1e ti0e la0e ti0e...%
          do1e do2e re2e do2e ti1e ti0e do1e ti0e la0e la1e so1e la1e ti1e ti0e mi1e re1e...
          do1e do2e re2e fa2e mi2e mi1e so1e mi2e do2e fa2e mi2e fa2e re2e so1e fa1e so1e...%
          mi1e so1e so1e so1e so1e so1e so1e so1e mi1e mi1e mi1e mi1e mi1e mi1e so1e so1e...
          fa1e fa1e fa1e do2e do2e do2e do2e do2e do2e do2e la1e la1e so1e so1e re2e ti1e...%%
          so1e mi2e mi2e mi2e re2e re2e re2e re2e do2e do2e do2e do2e so2e so2e so2e so2e...
          la2e la2e la2e la2e so2e so2e so2e so2e la2e la2e la2e la2e ti2e ti1e ti1e ti1e...%
          do2e do1s re1s mi1e do1e ti0e ti1s do2s re2e ti1e la1e la0s ti0s do1e la0e ti0e so1s fa1s mi1e re1e...
          do1e mi1s re1s do1e fa1e mi1e do1s re1s mi1e so1e fa1e la1s so1s fa1e mi1e re1e so1s fa1s mi1e re1e...%
          mi1e do2s ti1s do2e mi1e so1e so1s la1s ti1e so1e mi1e do2s re2s mi2e do2e mi2e mi2s re2s do2e ti1e...
          la1e la1s so1s la1e ti1e do2e mi2s re2s do2e mi2e fa2e do2s ti1s la1e la1e so1e re1e so1e so1e...%
          so1f so1f so1f so1f  do1f do1f do1f so1f...
          fa1f fa1f so1f so1f  fa1f do1f do1f do1e ti0e...%
          do1f do2f ti1f ti1f  la1f la1f so1f so1f...
          do1f do1e re1e mi1f mi1f  do2f do2f ti1f ti1f...%%
          do2f];

% cello
c1 = [cello cello cello cello cello...
      cello cello cello cello cello...
      cello cello cello cello cello...
      cello cello cello cello cello...
      cello cello cello blkf];
% violin1
v1 = [blkblock violin blkblock blkblock];
% violin2
v2 = [blkblock blkblock violin blkblock];
% violin3
v3 = [blkblock blkblock blkblock violin];


% Get dirty
s = c1+v1+v2+v3;
s = s/max(s);

sound(s,fs);

7. 在matlab中IntLp函数的源代码

经查询,matlab不存在intlp这个函数
如果需要matlab中任意函数的源代码,可以在命令窗口中直接输入“type fun”其中fun为你想要查询的函数名
例如,需要查询“mean”函数(求均值函数),直接在命令窗口输入“type mean”,效果如下图所示


在matlab中IntLp函数的源代码

8. matlab中找到源代码怎么用

为什么不呢?如果是一般用来选择的话,如果想跳出的循环就是用休息,跳出循环的每一步再回到下一个循环的一部分继续使用下去。MATLAB没有。即使C,转到不推荐。标准顺序程序结构完全避免了。哦,这就是它的意思。想跳过那些行,全部选中,然后按Ctrl + R的所有音符,颜色变绿。要恢复,选择它们,然后按Ctrl + T。