???error: Assignment has more non-singleton rhs dimensions than non-singleton subscripts.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
g=fileread ('e:\dfiles\a(3).dat');
f=['e:' filesep 'dataf'];
x=size(g,1);y=size(g,2);
a=dir(f);
data(x,y,6)=zeros(1,1,1);
j=0;
for i=3:8
j=j+1;
data(x,y,j)=importdata(fullfile(f,a(i).name)); // error in this line
end
0 comentarios
Respuesta aceptada
Geoff
el 11 de Abr. de 2012
I think you have a slight misconception about how to initialise your data sets. Start with this:
data(x,y,6)=zeros(1,1,1);
I think what you mean is this:
data = zeros(x,y,6);
Now, I'm assuming your data files specify a row and column count as the first two values? Is this on the first line? Is every file the same?
In that case you may need to specify the NHEADERLINES parameter for importdata
doc importdata
I'll assume spaces as delimiter and 1 header line:
for n = 1:6
filename = fullfile(f,a(n+2).name);
X = importdata(filename, ' ', 1);
if size(X,1) ~= x || size(X,2) ~= y
warning( ['Ignoring ' filename ': Wrong dimensions'] );
continue;
end
data(:,:,n) = X;
end
We can only hope that your values for x and y are correct from that call to fileread
2 comentarios
Más respuestas (1)
Walter Roberson
el 11 de Abr. de 2012
What you show is going to give you a problem unless importdata() happens to import exactly one value.
Ver también
Categorías
Más información sobre Data Import and Export en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!