# Eric Sofen

Last seen: 12 dagar ago Active since 2018

Followers: 0   Following: 0

#### Feeds

View by

Create excel file from json variable value
I'm roughing this a bit since I don't have your JSON data files, but the below approach puts your file names in a table, then us...

Sort rows of a table by column within a variable
There isn't a one-line solution to this, but here's another approach that hoists the data you want to sort by out of the table a...

Frequency of unique items per month from timetable data
I think groupcounts will also solve your problem (it would be helpful to have some sample data in the question in a form I could...

Find locations of a value in 3-D matrix (lat x lon x time) and take the two time steps before and after those selected values
Since you're using lighting as a logical mask on the precipitation data, you can shift the array one or two time steps and re-ap...

mer än ett år ago | 0

Rank stock returns by month
First off, get your dates into datetime rather than YYYYMM doubles! Then, you can use groupsummary to group the data by month a...

mer än ett år ago | 0

Retime Yearly Maximum - Finding Corresponding Dates from Timetable
This example gives another way to get the time when the max occurred. See the findMax function and how it's used in rowfun. The ...

mer än ett år ago | 1

How to extract specific dates from a datetime table?
If you know all the datetimes have 10:00:00 time components and you're just matching dates, timetable subscripting does that dir...

mer än ett år ago | 2

Automatically create a several layer structure from a cell array
Another approach is to string this out into a table, converting what were labels along each dimension into grouping variables. S...

mer än ett år ago | 0

Problems trying to find fakes dates.
The reason datetime(2005,2,29) works is that we want to support constructing a vector of datetimes: datetime(2023,1,1:100) Not...

mer än ett år ago | 0

Case insensitivity for keys in outerjoin and ismember?
We've had a variety of requests for a "lenient" join, but there's also a variety of different interpretations of "lenient." :-) ...

mer än ett år ago | 1

| accepted

How I can create a while cycle that ends after a sepecific time
I think timer is likely to give you better precision for this sort of thing than tic/toc (tic/toc is better for timing performan...

mer än ett år ago | 0

convert cell array into date and time string
As much as I love string, there's no need to do an extra type conversion. Just concatenate the elements of the cell into a char ...

mer än ett år ago | 0

Break array or timetable into smaller versions and find max value
Normally, groupsummary or varfun should be the starting point for grouped calculations like this, but your particuar problem is ...

mer än ett år ago | 1

result in table format or excel format
It's a little circuitous, but you can use writelines to write the char vector to a text file, then use the power of readtable to...

mer än ett år ago | 1

Merge tables with different columns and for matching columns update missing values in left table with values from right table
This is a tricky combination, and not doable in a single join right now. As you say, the outerjoin of A and C to create a table ...

mer än ett år ago | 0

How to extract all the data between two different dates?
I'd recommend using a timerange. Isbetween returns a logical vector based on a vector of datetimes. This can then be used to in...

mer än ett år ago | 1

How can I isolate and subplot June from the whole year?
Using datenum is no longer recommended. I'd encourage you to use datetime for date and time calculations in MATLAB. Among other ...

mer än ett år ago | 0

We're aware of this issue and have been working to reconcile it. The time vectors in Simulink and timetable are constructed in b...

nästan 2 år ago | 0

Read netCDFs in loop and export to table with different sizes
I would suggest using timetable and the synchronize method. I assume nlevel is the sensor data? If so, build up a cell array of...

nästan 2 år ago | 0

| accepted

divide year time data into days and nights
Steve beat me to it, but here's another solution that uses the datetime isbetween function. SunriseSunset = table((1:365)',date...

nästan 2 år ago | 0

| accepted

Add code to have switch repeat if a case is not met
A while loop is one way to accomplish this. Also note that you can use lower() to reduce the number of cases. max_number = na...

nästan 2 år ago | 0

Here's another slightly different approach. There's no need to replace "/" with "-" for datetime to parse it. Duration can parse...

ungefär 2 år ago | 0

Convert DoY and hour to datetime format
The datetime constructor is forgiving about day values that don't fit within a particular month and wrapping them appropriately:...

ungefär 2 år ago | 0

Compare table variables with input list and replace missing vars with NA
Readtable and outerjoin do the trick (xlsread is discouraged at this point - readtable is preferred). FYI, there's also a join L...

ungefär 2 år ago | 2

Sorting/Grouping based on date for all years
The isbetween function can also help simplify a lot of the logical indexing to pull out the ranges of interest. tt = readtime...

ungefär 2 år ago | 1

How to make the following code valid for tables not only matrices
There are a few ways to rework the indexing to work with tables. By the way, I'm not sure what the loop does (ied doesn't appear...

ungefär 2 år ago | 0

How do I find a single value by corresponding data in 2 different tables?
It sounds like you are trying to align these two things based on time? If so, check out the synchronize method of timetable. The...

mer än 2 år ago | 0

Replace string values in a table
This is what categorical is built for! When you create the categorical, you can specify the data, value set, and category names....

mer än 2 år ago | 0

How to extract table data based on column values?
One thing to watch out for is that the char vectors contained in the cell arrays (celltrs) can vary in the number of characters,...

mer än 2 år ago | 0

| accepted

I want to separate each gait cycle and keep each cycle in a row of a table.
If you separate each cycle into a separat row, the rows will likely have data of different lengths, which then gets hard to work...

nästan 3 år ago | 0

| accepted