Answered
Vectors of seeming identical length, are supposedly not equal in length, how to fix?
Read the FITGAUSS documentation: https://www.mathworks.com/matlabcentral/fileexchange/7489-fitgauss The order of your input ar...

3 years ago | 0

| accepted

Answered
Creating an augmented matrix a set of matrices
A = cat(3,[1,3;0,1],[1,1;1,1],[0,0;0,0]); C = num2cell(A,1:2); X = 1+tril(toeplitz(1:numel(C))); C = [{zeros(2)};C(:)]; M = ...

3 years ago | 1

| accepted

Answered
find the closest datetime
I have a datetime column with the format HH:mm:ss.SSSS and for which I'm loooking for the closest datapoint to a time in a forma...

3 years ago | 0

| accepted

Answered
How to list all tasks in a table and sum up total time spend on each?
You can do this in just a few lines of code. Don't fight MATLAB with multiple nested loops! The data would be so much easier to...

3 years ago | 2

Answered
How to put value from one matrix into another matrix
A = [3:42;rand(1,40)].' B = [6,45,18,24,33;5,12,17,23,32;4,11,16,22,31;3,10,15,21,30] R = nan(size(B)); [X,Y] = ismember(B,A(...

3 years ago | 0

Answered
How to find the order of the power of A matrix?
A = [1,0,1;1,1,0;1,0,0]; B = A; for n = 2:5 B = mod(B*A,2); if isequal(B,eye(3)) break end end n B

3 years ago | 1

Answered
How to loop over a structure in matlab
As far as I can tell, this is your data structure (for simplicity I will define only two field Names, but the code works for any...

3 years ago | 0

| accepted

Answered
Rebuilding a 3D matrix
A1 = A(:,:,[2,5,7]); A2 = A(:,:,[1,6,10]); A3 = A(:,:,[3,4,8,9]); .. change values B = nan(10,10,10); B(:,:,[2,5,7]) = A1; ...

3 years ago | 1

| accepted

Answered
How to save a vector from each iteration in a loop in a matrix?
Take a closer look at your preallocation. What does SIZE(..) return?: size(230,300) so your preallcoation zeros(size(230,300)...

3 years ago | 1

| accepted

Answered
Cropping several images inside a for delivers empty cells
for K=1:10 % <- uppercase I_{k}=imcrop(I{k},RECT); end % ^ lowercase ^ MATLAB is case-sensitive, so you need to make th...

3 years ago | 0

| accepted

Answered
Reorganization of data in matrix
You could DOWNLOAD Jos' excellent PADCAT: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and use it somethi...

3 years ago | 0

| accepted

Answered
How to extract the months from a datetime table?
S = load('DateStamp.mat') T = S.DateStamp; T.month = T.date; T.month.Format = 'MMMM' But I am guessing that your actual goal...

3 years ago | 1

| accepted

Answered
How to save results matrix in multi dimensional matrix?
In general with MATLAB it is easier (even if more verbose) to iterate over indices rather than over data. For example: tV = 25...

3 years ago | 0

Answered
How to read a specially structured data file
fid = fopen('test.txt','rt'); mat = fscanf(fid,'%f',[19,Inf]).'; fclose(fid); display(mat)

3 years ago | 2

| accepted

Answered
How can I convert log(-1) to complex number
log10(-1)

3 years ago | 0

| accepted

Answered
For loop only running once
V = {'empty';'occupied'}; X = isnat(deptime(:,1)); T = V(1+X)

3 years ago | 0

Answered
How to overwrite matrix in txt file with another matrix?
Assuming that the //Events block always occurs last in the text file. Lets start by looking at the content of the two files: ty...

3 years ago | 0

Answered
MATLAB not sorting the text files in order.
You can DOWNLOAD and use my code NATSORTFILES: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filenam...

3 years ago | 0

| accepted

Answered
60 years of daily data; need to group separately by month and year
The simple MATLAB approach using GROUPSUMMARY and UNSTACK: M = categorical(datetime(1,1,1,"Format","MMM"):calmonths(1):datetime...

3 years ago | 0

Answered
reorder data in a matrix
This code finds all permutations with the minimum absolute difference as you specified here: A = [1,0,0,1,0; 1,1,0,0,0; 0,1,1,0...

3 years ago | 0

| accepted

Answered
FOR loop count to the end but the length of the array is different
"so there is no way to have the output vector with directly length of 5 ?" Of course there are multiple ways to achieve this, h...

3 years ago | 0

| accepted

Answered
How to combine multiple numbers into 1 number?
General solution: R1 = 2; R2 = 4; Zr1 = [0,0,0]; V = [R1,R2,Zr1]; N = 10.^(numel(V)-1:-1:0) * V(:)

3 years ago | 0

| accepted

Answered
Load files from two different folders
Do NOT use ADDPATH or CD or any other messing around with the MATLAB search path just for acessing data files. All MATLAB funct...

3 years ago | 0

| accepted

Answered
how get second derivative of a function with one variable? I keep getting not enough input arguments?
"it seems I did everything according to tutorials" Sort of: you defined a function that works on numeric data, but then you hav...

3 years ago | 0

Answered
Creating a graph of |sin(x)|
fun = @(x)abs(sin(x)); fplot(fun)

3 years ago | 0

| accepted

Answered
How to make random voids with for loop?
Why not just use a loop, something like this (aircode): % ... other model settings S = "e" + (1:10); for k = 1:numel(S) ...

3 years ago | 0

| accepted

Answered
Problem with writing datestr converted date time to a text file alongside other numeric variables
Have a look at this line: meteo = [DateTime(i,:) DOY(i,:) Ta_1_1_1(i,:)-273.15 TA_1_2_1(i,:)-273.15 Ts_1_1_1(i,:)-273.15 Ts_2_1...

3 years ago | 0

| accepted

Answered
Find data after 'matched' regular expresion in a file
The file you uploaded is encoded as UTF-16 LE with a BOM: https://en.wikipedia.org/wiki/UTF-16 https://en.wikipedia.org/wiki/B...

3 years ago | 0

| accepted

Answered
How to iterate over a char array and store them into a separate array?
"I want to be able create an array for each of these data structs ..." The simple approach is to use the structure array which ...

3 years ago | 0

Answered
Please help, I keep getting this error... Error using plot Not enough input arguments.
Rather than fiddling around with text and tickmarks, let MATLAB do it for you: V = [33.677;76.714;69.677;64.800;49.871;59.533;4...

3 years ago | 0

Load more