Answered
Sort elements in cell array in descending order
fun = @(v) sort(v,'descend'); new_cell_array = cellfun(fun, cell_array, 'UniformOutput', false);

3 years ago | 0

| accepted

Answered
Question on datestr to datetime conversion
datestr(timeseries(i),formatOut) Most likely TIMESERIES is a serial date number, the use of which is also discouraged and most ...

3 years ago | 0

| accepted

Answered
Import data from a bad format
TEXTSCAN is very efficient, and imports numeric data as numeric (i.e. no fiddling around with text): fmt = repmat('%f',1,25); ...

3 years ago | 2

| accepted

Answered
Reading uneven datasets from .mat file
Assuming that: the fields are in the required order (otherwise: you can sort them using ORDERFIELDS). the MAT file contains on...

3 years ago | 0

Answered
Using logical array to extract data without reshape
Note that saving those huge lats&lons matrices is rather waste of space: you actually only need the first row/column. "Is there...

3 years ago | 0

| accepted

Answered
readtable disfigures the CSV file header
data = readtable('headerFile.csv','ReadVariableNames', true, 'VariableNamingRule','preserve')

3 years ago | 2

| accepted

Answered
Something wrong with "floor" or "fix" functions or it's my code?
"Something wrong with "floor" or "fix" functions" Nope, in fact those functions do absolutely nothing in your code. "or it's m...

3 years ago | 1

| accepted

Answered
Read CSV into table but not all of the columns
First lets create a fake data file: writetable(array2table(rand(1e5,50),'Variablenames',"V"+(1:50)),"test.csv") Now lets try s...

3 years ago | 0

Answered
Hello. This is my code and I keep getting the error "This statement is incomplete." several times throughout but can't find the mistake.
layers = [ ... sequenceInputLayer(numFeatures) lstmLayer(numHiddenUnits) fullyConnectedLayer(numResponses) regressio...

3 years ago | 0

Answered
Using string() on double values without automatic rounding?
Rather than slow NUM2STR and then STRING, for a scalar the simpler and more efficient approach is to just call SPRINTF: sprintf...

3 years ago | 2

Answered
What is the output after each recursive function call?
"I am confused what is meant by a function call in this case," A function call is every time a function is called. Usually func...

3 years ago | 1

| accepted

Answered
Sum of all even index elements of a 1D array
"Why does it output 'No numbers in even positions' when the length of the array is greater than or equal to three and odd?" Bec...

3 years ago | 0

| accepted

Answered
How do I separate a matrix that has a nested matrix in a cell before importing it to Classification Learner?
That does not seem like the best use of XLSX: storing lots of numeric data as long strings of text just makes processing the dat...

3 years ago | 0

Answered
How to avoid linear indexing in operations involving matrices of different sizes
RESHAPE is very efficient, because no data gets moved in memory: A = rand(3,3); B = rand(3,2); idx = logical([0,1,1;0,1,1;0,1...

3 years ago | 0

| accepted

Answered
Unique name detection in table headers
The old-fashioned way: D = {}; % data H = {}; % header fid = fopen('test_data_for_forum.txt','rt'); while ~feof(fid) H{...

3 years ago | 0

Answered
Matlab 'borders' function not working. How to plot world map?
BORDERS is not inbuilt, it is a third-party function. You can download it here: https://www.mathworks.com/matlabcentral/fileexc...

3 years ago | 0

| accepted

Answered
How to filter a cell array from entries from another cell array
cell1 = {'aaa';'bbb';'ccc';'ddd'}; cell2 = {'bbb';'eee';'fff';'aaa';'ccc'}; cell3 = setdiff(cell2,cell1) https://www.mathwork...

3 years ago | 0

| accepted

Answered
How to find month wise mean and std from data of many years
"I think groupsummary is good function but I am unable to do that with my table data." Lets try it: T = readtable('data.csv')...

3 years ago | 0

| accepted

Answered
From a structure with "n" fields which each are a vector, I want to make a vector of length "n" made of the 3rd value of each vector of my structure.
You could use ARRAYFUN to iterate over the elements of a structure (but this will be slower than a well-written loop): file = s...

3 years ago | 0

| accepted

Answered
table2struct(struct2table(s)) does not return s when some fields are cell arrays with a single element
"Is there a way to guarantee that table2struct(struct2table(my_struct)) returns an identical struct array?" No. "Alternatively...

3 years ago | 1

| accepted

Answered
is there a command similar to map() that you can use in Matlab
"In Matlab is there anything similar to this command, can anyone tell me?" MAP is just a very basic kind of interpolation. MATL...

3 years ago | 0

Answered
How can I save the data from my function as a new .mat file?
Change newFilename = fullfile(filepath, name , '_RT.mat'); to newFilename = fullfile(filepath, [name,'_RT.mat']); % ...

3 years ago | 0

| accepted

Answered
fill a matrix within a loop
"tr_x_ch = 2752 is the actual reply" Then tr_x_ch is a scalar. The length of a scalar is exactly 1 (by definition), so your loo...

3 years ago | 0

| accepted

Answered
How to interpolate from a dataset using interp3?
"How to interpolate from a dataset using interp3?" It is very simple: don't use INTERP3. "It's completely unlogical" It is pe...

3 years ago | 0

| accepted

Answered
Unable to use value of type string as an index
"I wanted to get the details corresponding to each chain in separate matrices since all the details are clubbed into one single ...

3 years ago | 0

Answered
How to rearrange 2x5 matrix while keeping the size the same?
Rather than sorting the data, I suspect that you want something like this: x = [1, 5, 9, 4, 8; 3, 7, 2, 6, 10] y = reshape(x,[...

3 years ago | 1

| accepted

Answered
Convert a string array to numbers (RGB triplets)
S = ["0 0 0.17241"; "0 0 1"; "0 0 1"; "0 0 1"; "0 ...

3 years ago | 0

| accepted

Answered
categorical conversion to integer
M = categorical([0,1;1,0]) X = double(M); Y = int8(str2double(categories(M))); Z = Y(X)

3 years ago | 1

Answered
Best way to get date and time inputs from user and save as a datetime variable
No conversion back-and-forth is required: your approach of adding a DATETIME and DURATION object is the correct one. Sadly the D...

3 years ago | 0

| accepted

Load more