Substitute for eval function

2 ビュー (過去 30 日間)
Ninad Pimpalkhare
Ninad Pimpalkhare 2020 年 7 月 9 日
コメント済み: Ninad Pimpalkhare 2020 年 7 月 9 日
% load('DATA_FC');
% load('VARS');
%
% t=1;
% k=1;
% for j=1:1:13428
% for i=1:1:1001
% temp=[raw{k,1} '(i,t)=DATA_FC(i,j)'];
% % eval(temp);
% end
% if rem(t,36)==0
% k=k+1;
% t=1;
% else
% t=t+1;
% end
% end
I have data in DATA_FC --> which is of dimension 1001*13428
I have variables in VARS (373 variables, A1,A2....A373).
I want that these 373 variables each should contain the data 1001*36 dimension (data to be picked from DATA_FC)
Eval functions is very slow.
Can anyone please suggest a fast alternative code to this problem.
  2 件のコメント
Stephen23
Stephen23 2020 年 7 月 9 日
"Can anyone please suggest a fast alternative code to this problem."
load into output variables and access their fields:

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

採用された回答

KSSV
KSSV 2020 年 7 月 9 日
編集済み: KSSV 2020 年 7 月 9 日
It is not adivsed to use eval. You can reshape your data into what you want. Check below:
DATA_FC = rand(1001,13428) ; % random data for demo
[r,c] = size(DATA_FC); % get dimensions
nvars = 373; % number of variables needed
A = reshape(DATA_FC,[r,c/nvars,nvars]); % reshape
Now you can access your required variables...A1 will be A(:,:,1), A10 will be A(:,:,10)..etc.
  1 件のコメント
Ninad Pimpalkhare
Ninad Pimpalkhare 2020 年 7 月 9 日
Thank you that helped a lot. I had to only use eval function now to assign the particular variable name. Done in 1 min.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by