Answered
How to convert Data from 'yyyyMMddhhmm' format to datetime format
"... HS_date is a matrix of 1x52561 double values, the data is from 202201010000 to 202301010000." Abuse of decimal numbers to ...

5 years ago | 0

| accepted

Answered
Removing files that match a pattern from files that are on local PC
Assuming that no filenames are substrings of other filenames (e.g. all have the same number of characters): P = 'C:\Users\jorri...

5 years ago | 0

| accepted

Answered
Could anyone please help me to solve the issue in the following command line.
M = reshape(randperm(10),5,2)

5 years ago | 0

| accepted

Answered
How to duplicate rows of a matrix if the number of copies for each row are different?
out = repelem(A,b,1)

5 years ago | 0

| accepted

Answered
What is the use of "maxidx = max(A(:))+1" in the below code ? How does it work? Any alternate syntax for the below function?
"Can someone explain the use of "maxidx = max(A(:))+1;" in this code" The answer can be derived from https://www.mathworks.com/...

5 years ago | 0

| accepted

Answered
Keeping track of order of rows when sorting a matrix
"Or other than this is there any better method? " The MATLAB approach is to get the second output from SORTROWS, which is the s...

5 years ago | 1

| accepted

Answered
How can I get multiple values from arrayfun?
"However, I want to get 21000 double instead of 11000 cells. Is there any way I can get x1 as 2*1000?" Of course, just use a co...

5 years ago | 1

| accepted

Answered
Alternative to 'evalin' for pdepe solver
"Does anyone have a suggestion on how I can pass my 5 arguments into the pde function?" The recommended, documented, efficient ...

5 years ago | 0

| accepted

Answered
To add two datetime arrays , with millisecond values
You should be storing those times as duration objects (not as datetime objects) so you could simply add them. The solution to yo...

5 years ago | 0

| accepted

Answered
how to arrange vector to matrix?
x = [1,2,3,4,5,6]; m = hankel(x(1:4),x([4:6,1:3]))

5 years ago | 1

| accepted

Answered
textscan only reads first row of text file
fmt = 'Time%dG in body frame%f%f%fOmega%f%f%fr balane%f%f%fquat%f%f%f%fMag%f%f%f%f%f%f%f'; opt = {'Delimiter',{';',':',' '}, 'M...

5 years ago | 1

| accepted

Answered
Fill a vector with specific values from a matrix
a = [1,4,23,5;5,2,7,8;3,4,6,3]; b = a(a>4)

5 years ago | 1

| accepted

Answered
Input A of class cell and input B of class cell must be cell arrays of character vectors, unless one is a character vector.
Why are you inefficiently storing scalar numerics in cell arrays? Using numeric arrays would be much simpler and avoid this err...

5 years ago | 0

| accepted

Answered
Replacing Values of one matrix with another
isn_east = isnan(east); or simply: VV = Reference_E; VV(isnan(east)) = NaN;

5 years ago | 0

| accepted

Answered
Conversion of feet.inch to meter
Rather than abusing the definition of decimal numbers, a much better way to store feet and inches is in a matrix: FI = [6,5;5,9...

5 years ago | 1

| accepted

Answered
Why does the modulo function seem to break for large numbers?
You used a binary floating point number whose precision is limited to around 15-16 significant decimal digits. The output of MO...

5 years ago | 2

| accepted

Answered
Interleaved repmat (row duplication)
The simple and efficient approach is to use REPELEM: a = [1,0,0;0,0,1;1,1,1] b = repelem(a,2,1)

5 years ago | 2

| accepted

Answered
How to index into a table with more than 1 variable?
Where T is your table (do NOT use table as a variable name): out = T(ismember(T.name,a),:);

5 years ago | 0

| accepted

Answered
Is there any way to print values to more decimal places using fprintf?
As the FPRINTF documentation explains, you can specify the number of decimal digits: est = pi; fprintf('The value claculated f...

5 years ago | 0

| accepted

Answered
Shorten description of multiple fields and values in struct
Either use CELL2STRUCT: % Fake data: Varnames = cellstr("X"+(1:18)); VarDec = randi(9,5,3,18); % Convert to struct: C = num...

5 years ago | 1

| accepted

Answered
replace values in char array if conditions are met
C = {'00','15','30','45','00','15','30','45'}; V = str2double(C)/60; V = V+cumsum([0,diff(V)<0])

5 years ago | 0

Answered
Turning 2D array (58x23) into 4D array (58x1x23x1)
"I can't get any further than the above dimensions" It is not clear what the problem is: are you expecting trailing singleton d...

5 years ago | 1

| accepted

Answered
How to check if a variable exists and if yes display the variable.
"Why can't I check if this exists?" Of course you can, you just need to use function syntax and not command syntax: https://ww...

5 years ago | 2

Answered
Replace negative values with zero and values above 1 with 1, using loop in a 8760 x 1000 matrix
Much simpler and more efficient than using loops, where A is your array: ltz = sum(A<0,1); gto = sum(A>1,1); B = max(0,min(1,...

5 years ago | 3

Answered
Common substring index from two string arrays
a = ["frame01", "frame02", "frame03"]; b = ["capture00.jpg", "capture01.jpg", "capture02.jpg", "capture03.jpg", "capture04.jpg"...

5 years ago | 0

| accepted

Answered
less than against less or equal than
"Can someone tell me what is going on" Exactly as the comparison tells you, the value stored in that variable is greater than t...

5 years ago | 0

| accepted

Answered
Array prealocation - Extra array of zeros in 3D array
windows3D = nan(2000,5147,0); or use actual preallocation: N = size(eegDataNorm,1); windows3D = zeros(2000,5147,N); for k = ...

5 years ago | 0

| accepted

Answered
How to convert a char array field in a struct array to a string field in a vectorized fashion.
S = struct('code',{'CO128','TX457'}); S.code % checking tmp = num2cell(string({S.code})); [S.code] = tmp{:}; S.code % checki...

5 years ago | 1

| accepted

Answered
Create a matrix using rand function with a value range
0.004*rand(50,50)

5 years ago | 1

| accepted

Answered
for loops and storing values
"what can i do to solve this?" Use indexing into a preallocated array: c = nan(46,4); % <--- preallocate! for h = 1:23 f...

5 years ago | 1

Load more