Function variable output name to be the same as input variable name + "_pos".mat
Show older comments
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
Answers (1)
dpb
on 3 Dec 2016
fname=[inputname(1) '_pos']; % doc inputname for details
save(fname)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!