eval function using in load command

4 ビュー (過去 30 日間)
Ham Man
Ham Man 2022 年 12 月 21 日
コメント済み: Stephen23 2022 年 12 月 21 日
whay I'm getting this error when I use eval function to make it dynamic:
dp=500;flow='Q1',d=16/1000;try_num=1;,.....
load(eval(['D:\45deg_light_sheet_dp' num2str(dp) '_' num2str(flow) '_pipeID' num2str(d*1000) 'mm\try' num2str(try_num) '\loc_vel_ID' num2str(d*1000) 'mm_thresh' num2str(thresh_pln1) '_' num2str(flow) '_dp' num2str(dp) '_pln1_try' num2str(try_num) '_between two planes x1=' num2str(Xl_pln1) '-x2=' num2str(Xr_pln1) '_45deg_lightsheet_bin_new_name_variables.mat']));
Error: Invalid use of operator.
  1 件のコメント
Stephen23
Stephen23 2022 年 12 月 21 日
Why are you using EVAL()? it serves absolutely no purpose in your code.
Note that to make your code more robust, you should LOAD() into an output variable:
S = load(..);

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

採用された回答

Steven Lord
Steven Lord 2022 年 12 月 21 日
There is absolutely no need to use eval here. You're building a file name, not building code to evaluate.
dp=500;
flow='Q1';
d=16/1000;
try_num=1;
thresh_pln1 = 42; % You omitted this
Xl_pln1 = 999; % and this
Xr_pln1 = 314159; % this too
filename = ['D:\45deg_light_sheet_dp' num2str(dp) '_' num2str(flow) '_pipeID' num2str(d*1000) 'mm\try' num2str(try_num) '\loc_vel_ID' num2str(d*1000) 'mm_thresh' num2str(thresh_pln1) '_' num2str(flow) '_dp' num2str(dp) '_pln1_try' num2str(try_num) '_between two planes x1=' num2str(Xl_pln1) '-x2=' num2str(Xr_pln1) '_45deg_lightsheet_bin_new_name_variables.mat']
filename = 'D:\45deg_light_sheet_dp500_Q1_pipeID16mm\try1\loc_vel_ID16mm_thresh42_Q1_dp500_pln1_try1_between two planes x1=999-x2=314159_45deg_lightsheet_bin_new_name_variables.mat'
You could use this filename by using the functional form of load, as load(filename).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by