Function variable output name to be the same as input variable name + "_pos".mat

Hello,
I have a function to do stuff, the input of the function is a matrix array with name X, I call this function several times using different inputs and I want to save the result in a mat file where the variable name will be the same as the input name variable and the .mat name the same name as the input name + "_pos".
function [position]= position_min(X)
function code blablabla
position = some matrix result
save ('Posicion_min', 'position')*
end
Where X would be Mx and then My and so on, I call it like this
position_min(MxTB_min_etm)
This saves variable position under Posicion_min.mat. I want to save variable position change the name to "MxTB_min_etm _pos" and save as MxTB_min_etm_pos.mat

回答 (1 件)

dpb
dpb 2016 年 12 月 3 日
fname=[inputname(1) '_pos']; % doc inputname for details
save(fname)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2016 年 12 月 3 日

回答済み:

dpb
2016 年 12 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by