outputname of variable depending on inputname

5 visualizaciones (últimos 30 días)
Fabian Jakobs
Fabian Jakobs el 25 de Mzo. de 2020
Comentada: Fangjun Jiang el 25 de Mzo. de 2020
Hello everybody,
I wrote a function which smoothes data and I did it as general as possible, in order to that I renamed the input data to X:
function [] = Curvesmoothing(filename, curvename, range)
%% load data
X = load(filename, curvename);
X = X.(curvename);
...calculations
Xsmooth = [smoothedX]
But now I don't want to save the result with this meaningless name, but rather with its inputname and the information how many circumjacent values were used for the smoothing, i.e. curvename + "smooth" + range. And this into the origin file, because I want to be able to feed the function with data, undependent of its origin. Now is my Question how I get Matlab to rename Xsmooth into a specific name, depending on other variables.
e.g. I tried to do it by creating a structure, similiar to my approach above, but I ended up with a structure named S, which contains the array (with the right name & data), but I could not figure out how to extract this array (see below).
Q = curvename + "smooth" + range;
S.(Q) = Xsmooth;
save(filename, curvename + "smooth" + range , '-append')
I also already figured out how to specify the filename, but I don't want to create too many .mat files, in order to keep some tidiness in my data.
Best Regards
Fabian

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 25 de Mzo. de 2020
utilize inputname()
  2 comentarios
Fabian Jakobs
Fabian Jakobs el 25 de Mzo. de 2020
could you may clarify that? I cannot see how to use the function in my context
Fangjun Jiang
Fangjun Jiang el 25 de Mzo. de 2020
there are examples in "doc inputname"

Iniciar sesión para comentar.

Categorías

Más información sobre Preprocessing Data en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by