How to save a matrix data with a concatenated variable name?

1 回表示 (過去 30 日間)
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2022 年 1 月 17 日
編集済み: Stephen23 2022 年 1 月 17 日
I have an application to name the output data with concatenated variable name.
a={'PrimSpeed','SecSpeed'};
for i=1:length(a)
['FFT_' a{i}]=abs(fft(V(IS:Ns)))/Ns1;
end
The output data need to be saved in FFT_PrimSpeed.

採用された回答

Stephen23
Stephen23 2022 年 1 月 17 日
編集済み: Stephen23 2022 年 1 月 17 日
It is simpler and more efficient to use a structure:
C = {'PrimSpeed','SecSpeed'};
S = struct();
for k = 1:numel(C)
S.(C{k}) = abs(fft(V(IS:Ns)))/Ns1;
end
Even better would be to just use basic indexing.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by