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

Respuestas (1)

fname=[inputname(1) '_pos']; % doc inputname for details
save(fname)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Preguntada:

el 3 de Dic. de 2016

Respondida:

dpb
el 3 de Dic. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by