Answered
Converting date number datetime
inp = [315552; 315555; 315558; 315561; 315564; 324333] dt = datetime(1800,1,1) + hours(inp)

14 days ago | 0

Answered
how to separate columns from txt file
M = readmatrix('r4.4u_db.txt', 'TrimNonNumeric',true, 'Delimiter',{'\t',','})

15 days ago | 0

| accepted

Answered
Strange result from comparison
"Why does this happen?" Because of the accumulated floating point error. Lets have a look at the values involved, to a higher p...

15 days ago | 0

| accepted

Answered
Converting cell to array data with specific string
The simplest approach: M = readmatrix('test.txt', 'TrimNonNumeric',true)

15 days ago | 3

| accepted

Answered
Error using vertcat, dimensions of arrays being concatenated are not consistent
Use a string array rather that trying to vertically concatenate incompatible character vectors: Name = ["Beam On (UTC)"; "Beam ...

16 days ago | 0

| accepted

Answered
Limit value to a function
y = min(1750,y)

16 days ago | 1

Answered
Extract values from multiple txt file
First lets create some fake data files just for testing this code: writematrix(1:2,'file1.txt') writematrix(3:4,'file2.txt') ...

16 days ago | 1

| accepted

Answered
merge the cells from a structured array
https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.mathworks.com/matlabcentral/answers/16...

16 days ago | 0

Answered
Separating daytime and nighttime according to daily sunset and sunrise values
M1 = load('Data1.mat') D = M1.Data1; DT = datetime(D(:,1),'ConvertFrom','datenum') M2 = load('sunrise and sunset.mat') SR = ...

16 days ago | 0

| accepted

Answered
date time from filename
First lets create some fake data files just for testing the code: writematrix(1:3,'P02_PRO_ST_20221115_151337.csv') writematri...

16 days ago | 0

Answered
Split a char without spaces and arbitrarily characters
format long G txt = ' 17575 3.10705E+00-7.07230E+01-1.77433E-01-2.72479E-05-7.19082E-06-9.65426E-06 1.70247E-04 4.89104E-05...

16 days ago | 0

| accepted

Answered
How to call function repeatedly using arrays as variables?
You need to provide a function handle, not call the function (as you are doing): B = arrayfun(@myComparator, Va, Vb); % ...

17 days ago | 1

Answered
Table column of strings to a matrix.
A = ["[0 0 0 0 0 0 0 0]";"[0 0 0 0 0 0 0 0]";"[0 0 0 0 0 0 0 0]";"[1 1 1 1 1 1 1 1]"] M = cell2mat(cellfun(@str2num,A,'uni',0))...

18 days ago | 0

| accepted

Answered
Abbreviate regexp: match a if present, else match b
It is possible to combine them, but it will be fiddly and not very efficient because it requires in some way checking the entire...

18 days ago | 0

| accepted

Answered
Problem with double use of a for loop?
A-B

19 days ago | 0

Answered
Group number identification consecutive numbers
X = [1;0;1;1;1;0;0;0;1;1;1;0;1;1;0;0;1;1;0;1;0;0;1;1;0;1;1;1;1;0;1;1;1;1;1;;0;1;1;1;1;1;1;1;1;1;0;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;...

21 days ago | 3

Answered
multiply vector of (2x1) to each of the (2x2) matrix in a (2x2x145) double data
"I want to multiply a vector of (2x1) to each of the (2x2) matrix in a (2x2x145) double data,F." Use PAGEMTIMES https://www.mat...

22 days ago | 0

| accepted

Answered
Remove the loop from a sum of index expression
Hiding the loop even more (really everything uses loops, even vectorized code): % Example setup n = 5; m = 10; M = randn( m,...

22 days ago | 1

| accepted

Answered
How can i extract the numbers from string?
Here are two approaches: C = {'104p8.png','105.png','105p2.png','105p4.png','105p6.png','105p8.png','106.png','106p2.png','106p...

25 days ago | 0

| accepted

Answered
Read different folders by changing path with for loop
P = 'C:\Users\Alberto\Download\...\...\...'; D = dir(fullfile(P,'DATA*')); for k = 1:numel(D) F = fullfile(D(k).folder,D(...

25 days ago | 0

| accepted

Answered
How to decide, number or character!
A = ';A0sf1001p00'; X = isstrprop(A,'digit'); N = A(X)

25 days ago | 1

Answered
How to save an indefinite number of outputs to a struct
"Is there anyway to do this?" Of course. But forcing pseudo-indices into structure fieldnames is much less efficient and more c...

25 days ago | 1

| accepted

Answered
Rename File in a Different Folder
new = fullfile(prjNo + 'REPORT'+ date +'.txt'); % odd use of FULLFILE. movefile(fullfile('.','OUT','REPORT.txt'),fullfile('.','...

28 days ago | 0

| accepted

Answered
Problem reading double array from excel
READCELL et al import text as text, not as double. You could use STR2NUM on the text: C = readcell(..) N = str2num(C{1})

28 days ago | 0

| accepted

Answered
Update array elements with the element before
V = 1:6 Z = cumsum(V)

29 days ago | 0

Answered
modify anonymous function using eval
I assume that you want to select from a larger set of different parameters. In that case, put them all into one cell array and t...

30 days ago | 0

Answered
Sorting cell arrays with characters and numbers
"What method can be used to get the right order?" You could download my FEX submission NATSORT: https://www.mathworks.com/matl...

1 month ago | 1

| accepted

Answered
How to get the max value between two elements of two separate arrays?
The efficient MATLAB approach: a = [1,3,4,6]; b = [2,2,5,4]; c = max(a,b)

1 month ago | 1

Answered
Display double number with 6 digits exactly
sprintf('The number is %#.6g', 12.45) sprintf('The number is %#.6g', 2)

1 month ago | 1

| accepted

Answered
readtable to specify date format to avoid ambiguity on a single variable in file.
As the warning (it is not an error) message shows, set "inputFormat" (not "datetimeFormat"): FILENAME = 'testData.csv'; opts =...

1 month ago | 0

Load more