Accessing code for built-in functions

조회 수: 32 (최근 30일)
Fikret Taygun Duvan
Fikret Taygun Duvan 2022년 1월 20일
댓글: Steven Lord 2025년 8월 27일 21:15
Hi,
I cannot use the open or edit commands to see the source code for built-in functions. When I do it I can only see the comments that are included for that function but not the actual code.
I'm trying this on functions like plot.m and fft.m
I hope somenone can give me advice.
Best,
Taygun
  댓글 수: 1
Steven Lord
Steven Lord 2022년 1월 20일
What were you hoping to do with the source code for those built-in functions? If you were hoping to convert them to another language (specifically C or C++) some of them are supported by MATLAB Coder. fft is supported by MATLAB Coder, plot is not.

댓글을 달려면 로그인하십시오.

답변 (2개)

Max Heimann
Max Heimann 2022년 1월 20일
편집: Max Heimann 2022년 1월 20일
These functions are not accessible to users as they are MATLABs proprietary code. They are p-coded, which its matlabs way to obscure code. You can only see the header of p-coded files.
You may still place breakpoints and see what they do with the workspace, but you will not be able to see the source code.
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 1월 20일
more correctly, a lot of them are built-in functions coded in C or C++ with occasional Fortran as well.
Fikret Taygun Duvan
Fikret Taygun Duvan 2022년 1월 20일
Thanks for the answer Max.

댓글을 달려면 로그인하십시오.


Gerardo
Gerardo 2025년 8월 27일 20:39
did you try with dbtype?
then you just have to copy it on notepad++ and with select column delete the colum number to work on it
For example
% dbtype ode113
% Returns 670 lines as such
1 function varargout = ode113(ode,tspan,y0,options,varargin)
2 %ODE113 Solve non-stiff differential equations, variable order method.
3 % [TOUT,YOUT] = ODE113(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates
4 % the system of differential equations y' = f(t,y) from time T0 to TFINAL
5 % with initial conditions Y0. ODEFUN is a function handle. For a scalar T
6 % and a vector Y, ODEFUN(T,Y) must return a column vector corresponding
7 % to f(t,y). Each row in the solution array YOUT corresponds to a time
8 % returned in the column vector TOUT. To obtain solutions at specific
9 % times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =
10 % [T0 T1 ... TFINAL].
11 %
  댓글 수: 1
Steven Lord
Steven Lord 2025년 8월 27일 21:15
ode113 is a MATLAB function file that is included as part of MATLAB. But I wouldn't call it a built-in function in the same way that something like plot or fft are.
which ode113
/MATLAB/toolbox/matlab/funfun/ode113.m
which plot
built-in (/MATLAB/toolbox/matlab/graphics/graphics/graph2d/plot)
which fft
built-in (/MATLAB/toolbox/matlab/datafun/fft)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by