|
[reordering top-post]
"mishra" <mishradh@gmail.com> writes:
> Peter Boettcher wrote:
>> "mishra" <mishradh@gmail.com> writes:
>>
>> > Hi,
>> > I was trying to assign file as an array of y, like y(1)=load name.dat.
>> > Since I have lot of .dat files and I want to assign them as in an array
>> > of y vaules, to be used later in program. Can anyone advise me on this.
>>
>> Use a cell array:
>>
>> y{1} = load('name.dat');
>>
>> Or, since your name will be dynamic:
>>
>> for i=1:10
>> fname = sprintf('file%i.dat', i);
>> y{i} = load(fname);
>> end
>
> Thanks very much. But If I use it I am getting this message "Function
> 'plus' is not defined for values of class 'cell'."
I haven't used "plus" anywhere. On what line and for what code does
this error appear? Don't forget the curly braces when you go to
reference the images.
> I want to call 10 different files and want to assign them like
> y(1),y(2)..and so on. Please let me know how to do it. I am not sure
> how this code "fname = sprintf('file%i.dat', i);" will work.
I have already told you. As for the sprintf line, why not try it with
some different values of i and see what it does? If you have a
different way to obtain the file names, replace my line with your
line.
Is your difficulty dealing with the cell arrays? Then spend some time
and read about cell arrays in the documentation.
--
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
|