tall array assignment with tall logical vector
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
michel hillen
el 10 de En. de 2017
Comentada: Edric Ellis
el 11 de En. de 2017
"( )" Assignment
You can assign elements into a tall array using the general syntax A(m,n,...) = B. The tall array A must exist. The subscripts m,n,... cannot exceed the dimensions of A, and the first subscript m must be either a colon : or a tall logical vector. With this syntax, B can be:
- Scalar
- A tall array with the appropriate size
- An empty matrix, []
However, I get the following error message "In the assignment A(m,n,...)=B, B must be a scalar value.", when I execute my code. I am simply trying to proces some files consisting of 5 columns. The last column contains strings of the format '2016-12-31 00:01:00 UTC'. I want to convert this last column into the datetime data type. For this I think I first need to remove the trailing ' UTC', as including literal characters at the end of a datetime InputFormat does not seem to work (unlike, e.g., '2016-12-31T00:01:00' that can be formatted as 'uuuu-MM-dd''T''HH:mm:SS'). With the following code I try to remove the ' UTC' wherever it is present in my last column. The code fails at the last statement (and I have checked the sizes).
ds = datastore(some_path,'ReadVariableNames',true,'NumHeaderlines',0,'Delimiter',delimiter,'TextscanFormats',{'%s','%s','%s','%f','%s'},'TextType','string','ReadSize','file');
rdata = tall(ds);
TF = endsWith(rdata.UtcTime(:),' UTC');
lC = rdata.UtcTime;
B = replace(lC(TF,1),' UTC','');
lC(TF) = B;
Am I misinterpreting the documentation or what could be the reason for this error?
1 comentario
Edric Ellis
el 11 de En. de 2017
Thanks for reporting this. Yes, this is a mismatch between the documentation and the implementation. This form of assignment is not supported. ( help tall/subsasgn has a correct list of what forms are supported).
Respuesta aceptada
Guillaume
el 10 de En. de 2017
The documentation does not match the actual implementation by MathWorks. The error is generated at line 32 of fullfile(matlabroot, '\toolbox\matlab\bigdata\+matlab\+bigdata\+internal\+adaptors\GeneralArrayParenIndexingMixin.m') after the simple test if istall(b) (b being the assignor). So it is generated as soon as you try to assign a tall array regardless of whether or not its size matches that of the destination.
This is worthy of a bug report to Mathworks.
With regards to datetime, the input format can include a timezone, but you also have to specify which timezone you want the datetime in:
datetime('2016-12-31 00:01:00 UTC', 'InputFormat', 'yyyy-MM-dd HH:MM:ss z', 'TimeZone', 'UTC')
Más respuestas (0)
Ver también
Categorías
Más información sobre Tall Arrays 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!