outputname of variable depending on inputname

5 次查看(过去 30 天)
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

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2020-3-25
utilize inputname()
  2 个评论
Fabian Jakobs
Fabian Jakobs 2020-3-25
could you may clarify that? I cannot see how to use the function in my context

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Preprocessing Data 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by