Answered
How to select time range for many years?
Do NOT use deprecated DATENUM, DATEVEC, or DATESTR. Use the methods and properties of the DATETIME objects: DT = datetime(2010...

4 years ago | 1

| accepted

Answered
convert an array value into corresponding Matrix indices
A = repmat((1:10).',3,1) M = (1:10)==A

4 years ago | 0

| accepted

Answered
How to convert row-major linear indices to column-major indices?
S = [3,6]; % matrix size X = [1,8,14,9,4,11,18]; % row-major linear indices [Y,Z] = ind2sub(flip(S),X); V = sub2ind(S,Z,Y) % ...

4 years ago | 0

| accepted

Answered
How to unzip multiple files(zipped) present in different subfolders
inp = 'absolute or relative path to Folder 1'; out = 'absolute or relative path to the output folder'; unzip(fullfile(inp,'nam...

4 years ago | 1

Answered
Converting location of a 2x3 vector into a matrix with value 1
"However for a large matrix a this will be tedious." If you have a large matrix it may be better if it were a sparse array (whi...

4 years ago | 1

Answered
How to shuffle rows in pairs?
V = 1+mod(0:599,8).' % fake data M = reshape(V,2,[]); X = randperm(size(M,2)); V = reshape(M(:,X),[],1)

4 years ago | 1

Answered
Preallocating for speed with increments
Indexing would be a much better approach, rather than those inefficient low-level loops. Note that it is not that loops are gene...

4 years ago | 0

| accepted

Answered
Manipulating a structure for a more flexible plot
Data in a 3x1 structure array (rather than a scalar structure with nested cell arrays as you showed) means slightly simpler data...

4 years ago | 0

| accepted

Answered
Efficient way of performing operation on array after performing cumsum
A = [1,2,3;4,5,6;7,8,9]; B = cumsum(A,2); C = B./(1:3)

4 years ago | 2

| accepted

Answered
fgets write -1.000000e+00 in output file
while ~feof(file)

4 years ago | 0

| accepted

Answered
I'm trying to initialize a structure from a txt file which contains matrices and the field names
Assuming that every "system" contains exactly the same number of matrices: str = fileread('database_z.txt'); tkn = regexp(str,...

4 years ago | 1

| accepted

Answered
Concatenation of matrices with a specific pattern
N = 4; A = rand(3,3,N); B = rand(3,3,N-1); C = rand(3,3,N-1); D = repmat({zeros(3,3)},N,N); D(diag(true(1,N))) = num2cell...

4 years ago | 1

| accepted

Answered
How to check if all the data in the cell array are the same?
The simple and very efficient MATLAB approach is to use a comma-separated list: https://www.mathworks.com/help/matlab/matlab_pr...

4 years ago | 1

Answered
Sum matrix with repeating indices
A simple MATLAB approach: A = [1,2;1,-3;2,0;3,3;5,6;2,-4;4,0.5;7,9;7,2] [G,U] = findgroups(A(:,1)); M = [U,accumarray(G,A(:,2...

4 years ago | 0

| accepted

Answered
Adding Matching Data from multiple rows
Name = ["One";"Two";"Three";"One";"Two";"Three";"One";"Two";"Three";"Three"]; Num = [6;3;1;5;22;2;6;3;32;4]; inp = table(Name,...

4 years ago | 0

| accepted

Answered
Create a matrix composed of cross column per element moltiplication
B = (1:9).'+(0:3) N = size(B,2); V = nchoosek(1:N,2); M = B(:,V(:,1)).*B(:,V(:,2))

4 years ago | 0

| accepted

Answered
How to write my function output in various form?
This is how to do achieve what you asked for: function [out1,out2,out3,out4,out5,out6,out7] = yourFunction(..) .. out1 = ..; ...

4 years ago | 1

| accepted

Answered
Creating matrix from a loop between multiple files
Use arrays and indexing rather than numbered variable names. Use a more appropriate tool for importing textfile data, e.g. READ...

4 years ago | 2

| accepted

Answered
Joining tables with different number of coloums
"From my understanding there is no need for the number of coloums to be the same" If the number of columns in the key variables...

4 years ago | 0

| accepted

Answered
How do I convert dates to days?
Your example and explanation are inconsistent: your explanation shows difference between adjacent dates, your example vector sho...

4 years ago | 1

Answered
How to replace zero with one automatically in MATLAB
Here are three approaches: M1 = repelem(eye(6,6),1000,1) M2 = kron(eye(6,6),ones(1000,1)) C = repmat({ones(1000,1)},1,6); M3...

4 years ago | 0

Answered
How to display superscript in the command window.
You can use these characters: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts Lets try one: fprintf('y\xB2'...

4 years ago | 0

| accepted

Answered
picking numbers from matrix
M = [0,4,8;5,0,0;0,4,6;2,8,0;0,0,7] fh1 = @(v)v(randperm(numel(v),1)); fh2 = @(k)fh1(nonzeros(M(:,k))); V = arrayfun(fh2,1:si...

4 years ago | 0

| accepted

Answered
How can I print row number to matrix in matlab?
M = [1 0 1; 0 0 1; 1 1 0; 0 1 1] V = 1:size(M,1); Z = V(:).*M

4 years ago | 0

Answered
Compiling output vectors from each iteration of a for-loop into a Matrix
% New P and reaction force values with P2 varying P1_c = 1000; P2_c = -1000 : 100 : 1000; Fay_c = (P2_c + 2*P1_c)/3; Fdy_c ...

4 years ago | 0

| accepted

Answered
issue using 'sort'
The output is correct: just as the SORT documentation states, the second output is the index such that the first output can be o...

4 years ago | 0

Answered
how to add anew column to the table using MATLAB
M = randi(10,30,5); T = array2table(M,'variableNames',{'feat1','feat2','feat3','feat4','feat5'}) T.Class = repelem(["Healthy";...

4 years ago | 0

| accepted

Answered
Convert portion of matrix under the diagonal to column vector
Note that approaches which check if the data are zero (e.g. NONZEROS or ==0) are not robust, because you might have perfectly va...

4 years ago | 1

| accepted

Answered
Replace string values in a table
The simple MATLAB approach would be to use indexing: T = readtable('Typ.csv'); V = ["French";"Spanish";"Italian"]; T.Typ = V(...

4 years ago | 0

Answered
load variables in workspace except the ones with '.' in them
With a sufficiently old MATLAB release you can use this: https://www.mathworks.com/matlabcentral/fileexchange/42274-loadfixname...

4 years ago | 0

Load more