Take the 2-minute tour ×

I have a function in matlab.

function [MEAN STD]=result(data)


i set data's filename=ET1_A_l1(imported to workspace alrdy)(ET1_A_l1=[1;2;1;3;1;4] to find the mean and std of selected data(ET1_A_l1),and save the statistical feature into .mat form as shown in below:

>>[MEAN STD]=result(ET1_A_l1)

As a result, the name of save file is 121314.mat,and it is not 'ET1_A_l1',is there any good idea of using MATLAB's efficient code to change the filename correctly?


share|improve this question
What is your function, and how is it called? It looks quite mixed up in your question... –  glglgl Nov 23 '12 at 9:56
i edit the function again but stil cannot save the correct name file .. –  Tony YEe Nov 23 '12 at 10:10
add comment

1 Answer

up vote 1 down vote accepted

If I understand correctly, you can use inputname, which gives you the name of the function argument in the callers workspace:

function result(data)
    display(['file name should be ' inputname(1)]);  % name of the first parameter


>> result(ET1_A_l1);
file name should be ET1_A_l1
share|improve this answer
Thanks for your sharing!=) –  Tony YEe Nov 24 '12 at 3:08
add comment

Your Answer


