outputname of variable depending on inputname

6 ビュー (過去 30 日間)
Fabian Jakobs
Fabian Jakobs 2020 年 3 月 25 日
コメント済み: Fangjun Jiang 2020 年 3 月 25 日
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
Fangjun Jiang
Fangjun Jiang 2020 年 3 月 25 日
there are examples in "doc inputname"

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePreprocessing Data についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by