Error between cell and array (matrix)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear Everyone.
I have my data as attached picture include date, time and price (.txt) with format:
mm/dd/yyyy hh:mm:ss number
04/14/2004 15:00:00 80
04/14/2004 15:30:00 82
04/14/2004 16:00:00 80
......
I tried to run the beginning of my code:
% File contains three columns with date,time and index price respectively
data=Excludeweekendday({'IntervalCLG1996.txt'});
n_uni_t=unique(data(:,[2])); %Unique time stamps
intm=size(n_uni_t);
n=intm(1);
intm=size(data);
n_total_obs=intm(1); %Total number of observations given 5 minutes sampling
i=1;
j=1;
count=0;
while i<=n %Calculate amount of timestamps
for j=1:n_total_obs
if data(j,2)== n_uni_t(i,1)
count=count+1;
end
end
n_uni_t(i,2)=count;
count=0;
i=i+1;
end
end
It did not work with the error:
Undefined operator '==' for input arguments of type 'cell'.
Error in RawRVofnormalandlogreturns (line 23)
if data(j,2)== n_uni_t(i,1)
And
data(i,2)>0.4444 && data(i,2)<0.7431; %Boundaries in matlab format
Norm_data(j,1:3)=data(i,1:3);
When I try to run convert my cell to double with code: b = cellfun(@(x)str2double(x), data); The result of b is totally NaN as picture.
Could you help me find the problem in code and correct it?
I'm really appriciated your help! Picture:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154132/image.png)
0 comentarios
Respuestas (1)
Walter Roberson
el 18 de Jun. de 2016
Try changing
data(j,2)== n_uni_t(i,1)
to
data{j,2} == n_uni_t{i,1}
3 comentarios
Geoff Hayes
el 19 de Jun. de 2016
Editada: Geoff Hayes
el 19 de Jun. de 2016
Trung - what can you tell us about the dimensions and data type for data and n_uni_t? i.e. what do the following calls return?
size(data)
class(data)
size(n_uni_t)
class(n_uni_t)
Ver también
Categorías
Más información sobre Convert Image Type 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!