shivas007
Bioengineer
- Sep 11, 2005
- 8
Hi all,
Im working on a program which imports ( and loads) all the .mat files in to the workspace. The number of .mat files in the directory may vary to a significant number(say at around 1000 frames).To just give you an idea of what im doing, below is my code that i have written
files = dir('C:\Datasets\Number_of_Frames\*.mat');
for i=1:length(files)
eval(['importdata ' files(i).name ]);
eval(['frame_' int2str(i) '=ans']);
end
Im getting the output for this program correctly in the workspace, like below
frame_1 <2000X100 double>
frame_2 <2000X100 double>
frame_3 <2000X100 double>
frame_4 <2000X100 double>
frame_5 <2000X100 double>
frame_6 <2000X100 double> ..so on until frame_n
My problem here is that I want to push all these frames in to an array (say list[]), so that i can reference the frame_1 as list(1),frame_2 as list(2) and so on. I want to do this array functionality in the above mentioned program itself and added a statement for array in the routine as follows ( array d[] and statements d,:,i).. and d{i}, i tried both)
files = dir('C:\Datasets\Number_of_Frames\*.mat');
for i=1:length(files)
d=[];
eval(['importdata ' files(i).name ]);
d,:,i)= eval(['frame_' int2str(i) '=ans']);
%%%% d{i}=[{eval(['x_' int2str(i) '=ans'])}];
end
But im getting an error like
" ??? Error: The expression to the left of the equals sign is not a valid target for an assignment.
Error in ==> importing_multiple at 5
d,:,i)= eval(['frame_' int2str(i) '=ans']);"
and the same error when i used d{i} too.
Can anyone of you guys please help me out in this array implementation.I even tried using the cell arrays but im not able to get the syntax right.Please pour in your valuable help.Thanks a zillion.
Im working on a program which imports ( and loads) all the .mat files in to the workspace. The number of .mat files in the directory may vary to a significant number(say at around 1000 frames).To just give you an idea of what im doing, below is my code that i have written
files = dir('C:\Datasets\Number_of_Frames\*.mat');
for i=1:length(files)
eval(['importdata ' files(i).name ]);
eval(['frame_' int2str(i) '=ans']);
end
Im getting the output for this program correctly in the workspace, like below
frame_1 <2000X100 double>
frame_2 <2000X100 double>
frame_3 <2000X100 double>
frame_4 <2000X100 double>
frame_5 <2000X100 double>
frame_6 <2000X100 double> ..so on until frame_n
My problem here is that I want to push all these frames in to an array (say list[]), so that i can reference the frame_1 as list(1),frame_2 as list(2) and so on. I want to do this array functionality in the above mentioned program itself and added a statement for array in the routine as follows ( array d[] and statements d,:,i).. and d{i}, i tried both)
files = dir('C:\Datasets\Number_of_Frames\*.mat');
for i=1:length(files)
d=[];
eval(['importdata ' files(i).name ]);
d,:,i)= eval(['frame_' int2str(i) '=ans']);
%%%% d{i}=[{eval(['x_' int2str(i) '=ans'])}];
end
But im getting an error like
" ??? Error: The expression to the left of the equals sign is not a valid target for an assignment.
Error in ==> importing_multiple at 5
d,:,i)= eval(['frame_' int2str(i) '=ans']);"
and the same error when i used d{i} too.
Can anyone of you guys please help me out in this array implementation.I even tried using the cell arrays but im not able to get the syntax right.Please pour in your valuable help.Thanks a zillion.