tall array assignment with tall logical vector
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
michel hillen
il 10 Gen 2017
Commentato: Edric Ellis
il 11 Gen 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 Commento
Edric Ellis
il 11 Gen 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).
Risposta accettata
Guillaume
il 10 Gen 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')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Tall Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!