f



Current function name in Matlab

Is there a wat to programmatically find the name of the function that
Matlab is currently executing. I want to use the function name for
error/debug logging of my functions?

Thanks,
Venkat


0
veaswar (2)
3/8/2008 10:46:03 PM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader. Post Follow

3 Replies
924 Views

Similar Articles

[PageSpeed] 38

veaswar@gmail.com wrote in message
<fd986784-2236-42a3-a0a6-2d3e1ba37df3@i7g2000prf.googlegroups.com>...
> Is there a wat to programmatically find the name of the
function that
> Matlab is currently executing. I want to use the function
name for
> error/debug logging of my functions?
> 
> Thanks,
> Venkat
> 
> 

help mfilename

Bruno
0
b.luong (628)
3/8/2008 11:12:02 PM
On Mar 8, 4:12 pm, "Bruno Luong" <b.lu...@fogale.fr> wrote:
> veas...@gmail.com wrote in message
>
> <fd986784-2236-42a3-a0a6-2d3e1ba37...@i7g2000prf.googlegroups.com>...
>
> > Is there a wat to programmatically find the name of the
> function that
> > Matlab is currently executing. I want to use the function
> name for
> > error/debug logging of my functions?
>
> > Thanks,
> > Venkat
>
> help mfilename
>
> Bruno

Thanks. That works well in cases where there is one function in a
file. Even if a change my function name, error printfs do not have to
change:

For example:
-------------------------------------------
function  [status result] = test()
sttaus = 1;

try
---
catch ME
  status = 0;
  fprintf(2, 'Error in function %s:.....', mfilename);
end
-----------------------------------------
0
veaswar (2)
3/9/2008 11:04:50 PM
In article <2097c426-eb0a-40f6-a9c0-574ff6906ed0
@e10g2000prf.googlegroups.com>, veaswar@gmail.com says...
> On Mar 8, 4:12 pm, "Bruno Luong" <b.lu...@fogale.fr> wrote:
> > veas...@gmail.com wrote in message
> >
> > <fd986784-2236-42a3-a0a6-2d3e1ba37...@i7g2000prf.googlegroups.com>...
> >
> > > Is there a wat to programmatically find the name of the
> > function that
> > > Matlab is currently executing. I want to use the function
> > name for
> > > error/debug logging of my functions?
> >
> > > Thanks,
> > > Venkat
> >
> > help mfilename
> >
> > Bruno
> 
> Thanks. That works well in cases where there is one function in a
> file. Even if a change my function name, error printfs do not have to
> change:
> 
> For example:
> -------------------------------------------
> function  [status result] = test()
> sttaus = 1;
> 
> try
> ---
> catch ME
>   status = 0;
>   fprintf(2, 'Error in function %s:.....', mfilename);
> end
> -----------------------------------------
> 

From the help: 
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/mfilename.html

To get the names of the callers of an M-file, use dbstack with an output 
argument.

This may help with the function name you are looking for.

-- 
Loren
http://blogs.mathworks.com/loren/
0
loren5358 (941)
3/10/2008 12:05:35 PM
Reply:

Similar Artilces:

MATLAB function name passed in a function call
I have a statement as follows: wc = FWT_PO(x_use,4,QMF) where QMF is the name of a MATLAB function (QMF.m, the Quadrature Mirror Filter function). x_use is an array. The function FWT_PO is just regular MATLAB statements. Problem is that control immediately goes to QMF.m whereupon it bombs out with a "not enough input arguments" error message. Do not understand this form of function call line, cannot find it described in the MATLAB "Help", & thus do not understand cause of the error or how to fix. In article <eed8cdf.-1@webx.raydaftYaTP>, kbannister@ara.com says...

How to fix this " Warning: Function j has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. "
I am using Matlab r2015a on windows 10. so, how to fiz this? On 03/21/2015 4:09 AM, Altin Guberi wrote: > I am using Matlab r2015a on windows 10. so, how to fiz this? Do what it says, rename the m-file you created (or got from somewhere else) to some name that doesn't conflict. -- ...

embedded matlab function MATLAB R2009a
I downloaded the MS visual C++ 2008 Express Edition and the SDK as detailed in http://www.mathworks.com/support/solutions/en/data/1-6IJJ3L/?solution=1-6IJJ3L My embedded function didnt work at the beginning because I did "mex -setup" before I installed my SDK. But after I installed the SDK, I ran "mex -setup" in Matlab once again and choose the MS visual C++2008 as my compiler. Then, my embedded matlab function worked. Thanks to the contribution from above! ...

Matlab comiler and simple matlab function
I am trying to create an exe from a matlab function which doubles the number you give it. matlab function: test.m function [output] = test (number) %return double the input number output = 2*number; disp(output); run matlab compiler at command line with: mcc -mv test.m with the resulting exe: test.exe However when I run it at DOS prompt: test 1 I am returned a value of 98. I thought that maybe this was some octal description of the output, but 98 oct is not 2 decimal. Some other results it returned: C:\Documents and Settings\alex\Desktop\lighttrans\Frank Work \test...

Call Matlab functions from mex (matlab function's input is string)
Here is my mex code: void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ char errBuff[1]={'A'}; //create mxArray pointer mxArray *mxerr; //copy errBuff to mxArray mxerr = mxCreateString(errBuff); //initialize mxArray with errBuff char array, return to pointer //call matlab function mexCallMATLAB(0,NULL, 1,mxerr, "errorCatcher"); //destroy mxArray mxDestroyArray(mxerr); //destroy mxArray printf("destroyed mex array\n"); }//end of mexFunction errorCatcher accepts string inp...

Conflict between property name and Matlab buit-in function name
I am writing some OOP code in Matlab and I wonder if there is any way to specific a function from the Matlab built-in class. The reason why I want to do this is because I want to be able to use some of the Matlab built-in function names (such as "mean" and "kurtosis") as property names of my class and use the corresponding builtin function to compute these property values. To illustrate my problem, I want to be able to do something like this: function value = get.mean( obj ) value = MatlabClass.mean( obj.values ) ; end Thanks for reading. Perhaps t...

what is the function name in Matlab?
Hello all: Given a masked region and dimension of an image, Matlab can return a image with indicated width and height and display masked region as a image. I knew matlab provides such function, but i don't remember the function name. does anyone know the name of that function? thank you On Sun, 04 Jun 2006 10:01:28 -0400, Daniel Mark wrote: > Hello all: > > Given a masked region and dimension of an image, Matlab can return a > image with indicated width and height and display masked region as a > image. > > I knew matlab provides such function, but i don't ...

Call a Matlab function from Java running in matlab.
Hi guys. I really apologize for asking this question, since I'm sure it is either basic or not possible, but I have been reading through the documentation and can't seem to figure this out, since the examples look like they just send and receive variables from the Java methods. Could anyone give me a short example of how to call a method from a Java object that causes some sort of action to be performed in MATLAB? For example, I would like to: 1) make a new object of MyClass from MATLAB called MyObject. 2) run MyObject.DoSomethingInMatlab() 3) have a statement in DoSomethingInMatlab...

call to matlab function from matlab GUI stalls
I have the following problem. I have created a simple Matlab GUI (for our purposes it can just be considered a Matlab function) which gathers some parameters and then invokes a perl script that in turn calls other perl and Matlab scripts to perform various calculations. If instead of using the Matlab GUI, I run the perl command from the unix prompt, the flow runs and concludes correctly. BUT if I invoke the flow from the Matlab GUI (function), then it runs correctly by calling various other perl and Matlab scripts, but then when it reaches the third Matlab function call, it consistently stalls...

EngSim: All Matlab features and functions. 2 to 20 Times Faster than MATLAB. Use the same programming syntax as MATLAB, ANSI C/C++, /C++. Good Graphics.
ENGSIM is an Engineering Simulation & Graphics Library for Microsoft Visual C++. It has all Matlab features and functions. 2 to 20 Times Faster than MATLAB. Very Easy to program. Use the same programming syntax as MATLAB, ANSI C/C++. Graphics Support is Very Good. Support Negative Indexing for Array/Matrix, Complex Array and Complex Matrix. Support Fix-point/Floating-point Communications Engineering and Signal Processing Simulation. Support Statistical Analysis. Support User- Defined Classes. Support User-Graphics Development ...

MATLAB talking to MATLAB?
For my project, I need to have a client program (MATLAB executable) talking to a server program (also MATLAB executable) to query data. Is there any easy way to accomplish that? I appreciate any help that I can get on that. Thanks. Cheers, Hoi Oops, I forgot to mention. There are multiple clients querying the server, so I guess serial objects + remote serial port wouldn't work. "Hoi Wong" <wonghoi.ee@gmail.com_> wrote in message news:f3ald6$gg4$1@news.Stanford.EDU... > For my project, I need to have a client program (MATLAB executable) > talking to a ser...

softly interrupting a MATLAB function
Does anyone know if there is a way to interrupt a long-running MATLAB function in such a way that one can execute a separate set of commands in a "catch"-type environment? Basically, I'd like to combine Cntl-C with error trapping, so that Cntl-C executes a catch block (i.e., try-catch-end), since it doesn't occur naturally. I have done something similar to this in a GUI environment, but in this case, it is in batch mode. Thanks, Mark Mark Abramson wrote: > Does anyone know if there is a way to interrupt a long-running MATLAB > function in such a way that one can exec...

MATLAB algorithm to MATLAB function code or C code
hallo firends, Can any body help me write this below code into MATLAB object oriented code or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length(t)); % create a DC signal that is constant of length t S=AC+DC; % total signal is AC signal + DC signal figure(1); plot(t,S); % plot signal. xlabel('time');ylabel('Signal'); title('Total Signal'); % filter components fAC=S-mean(S); % here is the AC component fDC=mean(S); % here is the DC component figure(2); plot(t,fAC,'r',t,fDC,'b'); % plot AC and DC signals legend('AC','DC'); xlabel('time');ylabel('Signal'); title('Signal with only AC component'); figure(3); plot(t,fDC,'b'); % plot DC signal legend('DC'); xlabel('time');ylabel('Signal'); title('Signal with only DC component'); figure(4); % best to plot in Fourier domain u=abs(fftshift(fft(S))); NumPoints=length(t); freq=(1/dt)*[1:NumPoints]/NumPoints; % create frequency axis freq=fre...

Run Matlab ... from Matlab
Hello, Is there any limitation to run Matlab from Matlab, as a system command, on Linux platforms ? I tried to start Matlab, both using the ! syntax (!matlab&) or the system command (system('matlab&')), the Matlab splash screen appears, but the new Matlab session closes rapidly . When I do the same with a script of mine (system('matlab -r "myscript"&')), my script is being executed, but Matlab finally crashes . If I remove the &, it works well, but the first Matlab session is blocked till I close the second one . I run Matlab on a Linux 64bits pla...

Compiling Matlab Function with mcc to use in other versions of Matlab
I am new to using mcc, mbuild, and mex - I'm attempting to use these to compile a function in matlab into a dll or exe so that I can re-use it in Matlab just as if it was still an m file. First, I wanted to verify that the code works, and I have received a demo license of the Matlab Compiler to test. As a simple example I've written the following function: function [output_var] = this_is_a_test(input_var) output_var = input_var*2; return I've tried multiple combinations of the mcc call in attempts to compile this function, some compile, some don't. First I tried this call: m...

Passing function arguments to Matlab via Matlab Engine
If someone can help me here , it will be greatly appreciated ... I was able to set up the Matlab Engine Call via C properly without any issues.. , done it via a C function calll .. something like this ... : ////////////////////////////////////////////////// #include <math.h> ..... int matlab_call(double Amp) { Engine *ep; mxArray *A = NULL, *result = NULL; if (!(ep = engOpen(""))) { fprintf(stderr, "\nCan't start MATLAB engine\n"); return EXIT_FAILURE; } ... } ////////////////////////////////////////////////// Now i want to...

the command to print out the matlab build in function scripts in the matlab window?
Does any body still remember the command to print out the matlab build-in functions? for example, how could I pull out the script for sqrt.m file? and similarly, the scripts for the simulink blocks? Thanks in advance. Cindy Cindy Li wrote: > Does any body still remember the command to print out the matlab build-in > functions? for example, how could I pull out the script for sqrt.m file? > and similarly, the scripts for the simulink blocks? >> type sqrt.m %SQRT Square root. % SQRT(X) is the square root of the elements of X. Complex % results are produced if X is not...

Function eval
Hello, i'm a braziliam master's degree student in applied mathematics. I found different results working with the eval function in versions 7.0 and 7.10 of Matlab, could you explain these differences? I managed to circumvent the problem with small changes in my algorithm, but I wonder what changed. I thank you for your cooperation. Adriano Verdério On Jun 23, 7:31=A0am, "Adriano Verd=E9rio" <adri...@gmail.com> wrote: > Hello, i'm a braziliam master's degree student in applied mathematics. > I found different results working with the eval fu...

MATLAB Function name in Masked Parameter
Hi, I have a Subsystem with a MATLAB Function Block. I want to use a Masked Parameter to get the name of the function (string) that will be used in the MATLAB Function Block. I´d try a variable with "Literal" Assignment (in Mask Editor) and did not work. I´d use the same name for the masked variable and the MATLAB Function parameters. Please help me Thanks Eric ...

how to dynamically execute the same name matlab function?
Hi all, I have two GUIs which were derived from the same original one GUI. Let's say I originally have a GUI A, I have copied this GUI and modified it and renamed to two new GUIs: A1 and A2. I have stored the two GUI under two different directories: C:\my projects\working\A1 C:\my projects\working\A2 The two GUIs consist of the same functions but in different directories and fulfill different functionalities... but if I do: which an_example_of_a_function, it always points to C:\my projects\working\A1, and the A2 version has been shadowed... How can I dynamically load the two pa...

Warning function has same name as MATLAB builtin
Hello, I am a new user of Matlab and I just installed R2007b with 50 toolboxes. I need Matlab to run an EEG data analysis platform called Chronux, so I installed the software by adding Chronux and subfolders to the path. The next time I started Matlab, a number of warning messages of this type appeared: Warning: Function /Applications/MATLAB_R2007b/toolbox/compiler/deploy/clc.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict. Warning: Function /Applications/MATLAB_R2007b/toolbox/compiler/deploy/clc.mexmaci has the same name as a M...

How to use new functions of new Matlab version in the old version of Matlab?
How to use new functions of new Matlab version in the old version of Matlab? Maybe it is not a good question but the situation is that I have got a MatlabR2008b on my laptop but the PCs of the university got only MatlabR2007b. I just want to use one particular function in the MatlabR2008b on the university machine. How can I do that? Just copy the toolbox? Or can I build the function as a .dll? Thanks! p.s: Of course I can not persuade the university to buy one MatlabR2008... I am also not the administrator; thus, I can not setup my MatlabR2008 on the university machine even I got th...

EngSim: All Matlab features and functions. 2 to 20 Times Faster than MATLAB
ENGSIM is an Engineering Simulation & Graphics Library for Microsoft Visual C++. It has all Matlab features and functions. 2 to 20 Times Faster than MATLAB. Very Easy to program. Use the same programming syntax as MATLAB, ANSI C/C++. Graphics Support is Very Good. Support Negative Indexing for Array/Matrix, Complex Array and Complex Matrix. Support Fix-point/Floating-point Communications Engineering and Signal Processing Simulation. Support Statistical Analysis. Support User-Defined Classes. Support User-Graphics Development http://mediachip.com/engsim billliu <william@mediachip.com&...

Display Matlab messages when the function is called by Labview via Matlab script
I use Labview (version 6.1) to send variables to Matlab (version 7.0.4) via Matlab script and&nbsp;I would like to display some message on the command window of Matlab. The messages are displayed&nbsp;when I call my Matlab function from the command window of Matlab but not when&nbsp;the&nbsp;function is called&nbsp;from Labview. &nbsp; Do you have any idea how to solve this problem ? &nbsp; Regards, &nbsp; Julien. ...

Web resources about - Current function name in Matlab - comp.soft-sys.matlab

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

Eating chocolate 'improves brain function' - study
... news for those with a sweet tooth - a recent study has found that regular chocolate consumption is associated with better cognitive function. ...

Resource sector may outsource finance functions to Asia
Outsourcing financial functions to Asia is one tactic struggling Australian energy and resources companies may use this year to survive the slump ...

Using Functions to Make Better Abstractions
... (code that is tightly coupled to its own implementation details). I was wrong. I was wrong because I had an incomplete understanding of functions. ...

A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003
**[A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003](http://www.j-bradford-delong.net/movable_type/2 ...

Yahoo Begins Grim Job of Closing Functions, Laying Off Staff
Yahoo Food is closing, and other digital magazines on tech, travel and beauty are also scheduled for closing or major cutbacks.

Don’t tase me, bro: Study shows being shocked by a Taser disrupts brain function
Researchers at Drexel shot a bunch of college students with 50,000 volts. The result? Short-term declines in cognitive function comparable with ...

How The U.S. Supreme Court Will Function Without Justice Scalia
... but in a fashion that could have frustrating ramifications for a number of major cases set to be decided. Here's how the court will function, ...

A 3D Printed Jet Engine Appears to Function
... jet engine . You may remember seeing a 3D printed jet engine grace our front page back in October. That one was beautiful didn’t function . ...

‘World Of Warcraft’ Alpha Removes Gold From Garrison Missions, Water Striders No Longer Function Everywhere ...
... build deploying soon to the alpha server, garrison missions no longer reward gold and the water-walking Water Strider mounts no longer function ...

Resources last updated: 2/24/2016 5:12:15 PM