Filter löschen
Filter löschen

What is the alternate to eval function in a forloop?

7 Ansichten (letzte 30 Tage)
Wiqas Ahmad
Wiqas Ahmad am 22 Apr. 2021
Beantwortet: Xingwang Yong am 22 Apr. 2021
EC = [0.0052 0.0104 0.0156 0.0234];
Reff =[4 8 12 16 20]
for i=1:length(FOV)
hold on
for j = 1:length(EC)
for k = 1:length(Reff)
filename1 = ['FOV_',num2str(FOV(i)),'mrad\',num2str(EC(j)),'\',num2str(Reff(k)),'um\out_resultsG_I0.dat'];
I have two folders in the directory in which I have the same data files.I am accessing the data at once. The path of the file is \FOV_1mrad\0.0052\4um\out_resultsG_I0 and \FOV_2mrad\0.0052\4um\out_resultsG_I0. The data file I have accessed by filename1=[......]. In the eval function,I is the variable inside the data file (out_resultsG_I0.dat) and getsignal is the file name in the directory. I'd like to avoid using eval function and to use the load function instead to acess the file and load the variable but I'm unable to do so for three loop indices. I need some help to write these three expressions in load function form applying the three loop indices.

Antworten (1)

Xingwang Yong
Xingwang Yong am 22 Apr. 2021
Using cell array should help
for i
for j
for k


Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by