Answered
Compact way to horizontally concatenate a cell array without the first columns of the cells
It rather depends on what you mean by "compact". C = {[2,4,6;1,3,8;6,9,1;6,1,1;5,5,2;3,7,8;9,2,4],[8,3,5;9,9,5;6,3,1;7,1,2;4,8,...

4 years ago | 0

| accepted

Answered
Combining two or more elements of vectors into 1
In MATLAB binary data is normally stored as character (see BIN2DEC, DEC2BIN, etc.). Perhaps STRING suits your needs (it gives e...

4 years ago | 0

Answered
How to extract numbers either side of a decimal place
The venerable NONZEROS could be used very effectively here: X = [1;2;3;4;5.4700;6;7;8;9.4100;10;11;12;13;14;15;16.4200]; X2 = ...

4 years ago | 1

Answered
Converting table column of cell arrays to column with comma separated values
A = [11;22;33;44;55]; B = {{'1'};{'2';'3';'4'};[];{'6';'7'};{'8'}}; T = table(A,B) X = ~cellfun(@isempty,T.B); T.B(X) = cell...

4 years ago | 0

| accepted

Answered
Import and process files from different folders in a loop
S = dir('C:/Users/Someone/Desktop/BlaBla/**/Output/file.txt'); for k = 1:numel(S) F = fullfile(S(k).folder,S(k).name); ...

4 years ago | 0

| accepted

Answered
Compact way to write matrices containing indices
A = [3;4;9;1;5]; B = [3,5;6,2;4,8;5,7;9,7]; [X,Y] = ismember(A,B(:,1)); M = A; M(:,2) = NaN; M(X,2) = B(Y(X),2)

4 years ago | 0

| accepted

Answered
Why is there aditional data loaded
" But this script is literally close everything and load the data into the workspace and it does all the extra stuff." No "extr...

4 years ago | 0

Answered
How to Extract Numbers after a particular String from a cell in Matlab
S = load('raw.mat'); raw = S.raw Method one: F = @(t)sscanf(t,'Rmin%f_Ymin%f',[1,2]); C = cellfun(F,raw(2:end,1),'uni',0); ...

4 years ago | 1

| accepted

Answered
Removing the space between %2d in a string statement.
Replace %2d with %d

4 years ago | 0

Answered
Put values from an array in a while loop into a table
There is no need to create lots of separate vectors, doing so would be very inefficient. Much simpler to convert the matrix usi...

4 years ago | 0

| accepted

Answered
interpulation of 2 axes in 3D matrix
format compact L = cat(3,[1,3,5;7,9,11;13,15,17],[3,5,7;9,11,13;15,17,19]) Xi = 1:3; Yi = [1,3,5]; Zi = [1,3]; [Xq,Yq,Zq] =...

4 years ago | 0

Answered
How to fill empty matrix elements based on surrounding values
V = [1;0;0;0;5;0;0;0;0;0;8;0;3]; The new approach: Z = fillmissing(V + 0./(V~=0), 'linear', 1) The old approach (repeat for e...

4 years ago | 0

| accepted

Answered
how to read a table and multiply its elements with eachother and store it in another table
If all you need are numeric operations across all columns then storing the data in one numeric matrix would make your task much ...

4 years ago | 0

Answered
Output names for splitEachLabel() in a for loop
"For this example, I am trying to end up with 10 new imageDataStores, trainImgs1, trainImgs2,...,testImgs1, testImgs2,...,testIm...

4 years ago | 0

| accepted

Answered
How to use multiple set of variables in a calculation and store the results?
Your current approach should be avoided: in general it is not considered good code design to store lots of data in executable co...

4 years ago | 1

| accepted

Answered
How to write to a .xlsx file and include a variable value in its filename
Of course, just use SPRINTF just as the documentation shows: https://www.mathworks.com/help/matlab/import_export/process-a-sequ...

4 years ago | 0

| accepted

Answered
Reshape a 2D Matrix to 3D in a block/tile wise manner and back(!)
Q1: "Can I do that only using reshape?" No, the order of the elements is different, so RESHAPE alone is insufficient (note that...

4 years ago | 0

| accepted

Answered
How to create a loop to add matrix columns?
The best approach is to avoid the need to write such bad code. The most important steps are: use a more suitable importing func...

4 years ago | 1

Answered
Extract only some specific elements of the arrays of a cell
C = arrayfun(@(n)num2cell(rand(1,5)),1:5,'uni',0) C{:} X = [2,5,1]; D = cellfun(@(d)d(X),C(X),'uni',0) D{:}

4 years ago | 0

| accepted

Answered
Interpolate Data associated to cartesian meshgrid to all direction (like polar interpolation)
Interpolating in 1D to: give the shape formed by rotation around X=Y=0 correctly return NaN for values outside the data domain...

4 years ago | 0

| accepted

Answered
Readtable gives unusual results reading data from a text file.
T = readtable('20160419-2010.txt','NumHeaderLines',0) T = readtable('20111118-0021.txt','NumHeaderLines',0) T = readtable('200...

4 years ago | 1

| accepted

Answered
How can i assign as an input one entire field of an multiple row struct when call a function ?
particle(1).Cost = [1 1]; particle(2).Cost = [2 2]; particle(3).Cost = [50 50] M = vertcat(particle.Cost) Then simply call y...

4 years ago | 1

| accepted

Answered
Question regarding matrix with NaN.
X = [9,6,9;0,2,nan;3,1,2] tmp = X.'; idx = ~isnan(tmp); cnt = sum(idx,1); M = [repelem(cnt,cnt);tmp(idx).']

4 years ago | 0

Answered
reordering matrix elements according to another matrix
A = [2 ; 4 ; 1 ; 3]; B = [12; 15; 20; 9]; [A,X] = sort(A); % or SORTROWS B = B(X)

4 years ago | 1

Answered
Why does Timer callback experience "too many output arguments" errors?
"But the function has no output... why does this happen?" Yes, it does, it has exactly one output argument. On this line: 'Tim...

4 years ago | 0

| accepted

Answered
A function that replaces any negatives with zeros
Simpler and much more efficient than your approach using indexing: function y = NoNegatives(x) y = max(0,x); end Why use slo...

4 years ago | 1

Answered
how do i print this matrix?
M = repelem([1,1;1,0;0,1],[1,2,3],[3,2])

4 years ago | 0

Answered
Import data into matlab but ignore subject name
P = 'absolute or relative path to where the subfolders are'; S = dir(fullfile(P,'**','*data_matrix.CSV')); for k = 1:numel(S) ...

4 years ago | 0

| accepted

Answered
How can I store the 100 rows of the array in one Matrix?
format compact X = rand(1,3,100) Y = permute(X,[3,2,1])

4 years ago | 1

| accepted

Answered
Extract row values from text file to add
V1 = readmatrix('file1.txt') V2 = readmatrix('file2.txt') Z = cumsum(0.5*(V1(2:end)+V1(1:end-1)) .* diff(V2))

4 years ago | 0

| accepted

Load more