how to correct the error in the datetime?

1 visualización (últimos 30 días)
Lilya
Lilya el 9 de Sept. de 2017
Comentada: Lilya el 10 de Sept. de 2017
Hi all,
I wrote the following script to extract some data from the list of files. The date time matrix is still shown some errors that I want to have it as double array, could anyone help me how to correct it?
Thank you so much.
a = dir('*.tuv'); %counting the number of profiles
b = length(a);
% creat NaNs matrix to import the extracted data
time = ones(978,length(b)) * NaN; %this is the error
tG = ones(978,length(b)) * NaN;
U = ones(978,length(b)) * NaN;
V = ones(978,length(b)) * NaN;
for i = 1:numel(a);
c = load(a(i).name);
hh=tuv2hfrc(a(i).name); %the related files that needs in the time extraction
time(1:m,i) = {[hh.matlab_time]}; % this as well
[m n] = size(c);
lat1 = c(:,1);lon1 = c(:,2);u = c(:,3);v = c(:,4);
Lat(1:m,i) = lat1;Lon(1:m,i) = lon1;U(1:m,i) = u;V(1:m,i) =v;
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Sept. de 2017
You have
time = ones(978,length(b)) * NaN; %this is the error
so you initialize time as being a numeric array. However, you later have
time(1:m,i) = {[hh.matlab_time]}; % this as well
so you are trying to store a cell array into a numeric slot.
Also notice that you have
b = length(a);
so b is a scalar that contains the length of a. and you have
time = ones(978,length(b)) * NaN; %this is the error
but with b being a scalar, length(b) is certain to be 1, suggesting that you have miscoded here. Perhaps you wanted
time = ones(978,b) * NaN;
or more simply
time = nan(978,b);
  3 comentarios
Walter Roberson
Walter Roberson el 10 de Sept. de 2017
Start a new Question
Lilya
Lilya el 10 de Sept. de 2017
Done.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by