Answered
Hello, can any one help me out? I have an mxn matrix with repeated columns. How can I get another matrix from this very one which is having no repetition of columns. Many thanks for anticipated assistance.
Transpose your matrix, use unique with the rows option, and then transpose again: A=[2 3 4 4 3; 1 2 4 4 2; 2 4 6 6 4] B ...

8 years ago | 0

| accepted

Answered
How to create a matrix of data points
You can create a 3D matrix: [xx,yy] =meshgrid(0:2) A = cat(3,xx,yy) so that A(:,:,k) gives you a specific k-th point ...

8 years ago | 0

| accepted

Answered
hi i have a question for example I have these two matrices a and b and I want to join them in one, how could I do that?
a=[1;3;5;7;9]; b=[2;4;6;8;10]; c = [a b] % concatenate. only works because a and b have the same number of rows c = c.'...

8 years ago | 0

| accepted

Answered
How do I change step interval in a frequency table in matlab
The help of TABULATE states: _If the elements of X are non-negative integers, then the output includes 0 counts for any integers...

8 years ago | 1

| accepted

Answered
Addressing folder with varying name of in a path
Take a look at the function FULLFILE. This may get you started. folders = {'AAA','BBB'} % brows for files for k=1:n...

8 years ago | 0

Answered
How to add matrices stored in a cell structure
This would be slightly more efficient: % Detect the elements that appear in the sum IndexWeights = find(weights>0); ...

8 years ago | 0

| accepted

Answered
How to assign specific value for character
Here is an easy way: A = {'r' 'b' 'g'; 'g' 'r' 'b'; 'b' 'r' 'g'} RGBval = [0.5 2 -3] [~,loc] = ismember(A,{'r','g','b...

9 years ago | 2

Answered
for loop - taking two vectors out of matrix
Do not create variables that have variable names! This will clutter your workspace. The best options are structure arrays, or c...

9 years ago | 1

| accepted

Answered
Selecting a range of rows at a time
You can loop over the rows, using for-loops or arrayfun: step = 30 ; fh = @(x) bandpower(A(x:min(x+step-1,size(A,2))...

9 years ago | 1

Submitted


padcatcell
concatenate cell arrays of unequal lengths

9 years ago | 1 download |

0.0 / 5

Answered
How to replace a NaN element with an preceeding element in a matrix using logical indexing?
If you can replace the NaNs with a zeros, you can use my function FILLZERO. If there are zeros in your matrix you can replace th...

9 years ago | 0

Answered
convert subset of matrix to vector in one line, Possible?
Use a reshape to convert the subset to a column vector: B = mean(reshape(A(:,i:end), 1, []), 'omitnan')

9 years ago | 0

Answered
How to replace a NaN element with an preceeding element in a matrix using logical indexing?
To replace NaNs by the preceding value in the row, assuming no NaN's in the first column: A = [ 2 1 1 1 1 ...

9 years ago | 0

Answered
How to create a Stop button in matlab
Take a look at my (old) STOPLOOP function on the File Exchange: <https://uk.mathworks.com/matlabcentral/fileexchange/20455> ...

9 years ago | 0

Answered
file sorting into sub folder
Why use matlab for this? Just call the OS mkdir('cat_1') system('mv *_1.txt cat_1/.') % linux dos('move *_1.txt cat_1...

9 years ago | 0

Answered
How do you find the average of specific columns for all rows?
Select the columns, and then perform the operation: A = magic(6) B = A(:,[1 2 6]) meanVal = mean(B,2)

9 years ago | 2

| accepted

Answered
separate matrices out of struct
Why? Apparently the three matrices are related. Keeping them in a single struct shows this relationship. If you need to access o...

9 years ago | 0

| accepted

Answered
5 person die roller
A trick is to start counting from 0 and use the function REM or MOD to determine the index numRolls = 1 ; while (randi(6...

9 years ago | 0

Answered
Interleaving arrays with different sizes
x = 1:5 y = 10:10:30 xy = [x y] [~, si] = sort([1:numel(x) 1:numel(y)]) result = xy(si)

9 years ago | 0

Answered
Why does datenum('null','yyyymmdd') return an actual date?
The help of DATENUM states: _Certain formats may not contain enough information to compute a date number. In those cases, ho...

9 years ago | 0

| accepted

Answered
Split array into training and testing
dataA = cumsum(ones(20,3)) % some test data p = .7 % proportion of rows to select for training N = size(dataA,...

9 years ago | 6

| accepted

Answered
how to calculate mean of cell arrays within cell array
I do not really get the (8x9) size. However, here is some code you may find useful: % some nested cell data for k1=1:4, ...

9 years ago | 0

| accepted

Answered
Polyfit with weights for not allowed points
You can simply concatenate the data into a single vector % xk, yk are your data sets. concatenate them into a single vector...

9 years ago | 0

Answered
Nested loops related question
for j = 1:N % commands here are executed N times if j < N % commands here are executed N-1 times, for exampl...

9 years ago | 0

Answered
random matrix 6*3 and i want set row according highest total of row set as first than lower
Let A be your matrix of values: rowsumA = sum(A,2) % sum over rows [~,ix] = sort(rowsumA, 'descend') % sort these sums i...

9 years ago | 0

Answered
From a cell to an array (besides cell2mat)
If all cells have a 1xN dimension, concatenation into a single row using comma-separate list expansion should work: C = {[1...

9 years ago | 0

| accepted

Answered
How to sum pages of a multidimensional array inside a structure array?
Given the description, I assume you have an array of structures A. Each element of this array has a field a which holds a 3D (11...

9 years ago | 0

Answered
Can I merge two matrices of different length with respect to a date column contained in both?
Take a look at INTERSECT. Something along these lines could work: [~,i,j] = intersect(A(:,1),B(:,1)) C = [A(i,:) B(j,2)]...

9 years ago | 0

| accepted

Answered
Linear fit between two sets of independent variables
Here are some commands you may find useful. Please take a look at the documentation X = [...] Y = [...] plot(X,...

9 years ago | 0

Answered
Using user input for a file name, and then reading a .txt file with the same name.
X = input('Number','s') filename = [X '.txt'] ; titlestring ['figure for file ' X] ; title(titlestring) You co...

9 years ago | 1

Load more