Réponse apportée
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 ...

plus de 8 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 8 ans il y a | 0

| A accepté

Réponse apportée
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.'...

plus de 8 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 8 ans il y a | 1

| A accepté

Réponse apportée
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...

plus de 8 ans il y a | 0

Réponse apportée
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); ...

plus de 8 ans il y a | 0

| A accepté

Réponse apportée
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...

presque 9 ans il y a | 2

Réponse apportée
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...

presque 9 ans il y a | 1

| A accepté

Réponse apportée
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))...

presque 9 ans il y a | 1

A soumis


padcatcell
concatenate cell arrays of unequal lengths

environ 9 ans il y a | 1 téléchargement |

0.0 / 5

Réponse apportée
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...

environ 9 ans il y a | 0

Réponse apportée
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')

environ 9 ans il y a | 0

Réponse apportée
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 ...

environ 9 ans il y a | 0

Réponse apportée
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> ...

environ 9 ans il y a | 0

Réponse apportée
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...

environ 9 ans il y a | 0

Réponse apportée
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)

environ 9 ans il y a | 2

| A accepté

Réponse apportée
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...

environ 9 ans il y a | 0

| A accepté

Réponse apportée
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...

environ 9 ans il y a | 0

Réponse apportée
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)

environ 9 ans il y a | 0

Réponse apportée
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...

plus de 9 ans il y a | 0

| A accepté

Réponse apportée
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,...

plus de 9 ans il y a | 6

| A accepté

Réponse apportée
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, ...

plus de 9 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 9 ans il y a | 0

Réponse apportée
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...

plus de 9 ans il y a | 0

Réponse apportée
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...

plus de 9 ans il y a | 0

Réponse apportée
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...

plus de 9 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 9 ans il y a | 0

Réponse apportée
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)]...

plus de 9 ans il y a | 0

| A accepté

Réponse apportée
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,...

plus de 9 ans il y a | 0

Réponse apportée
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...

plus de 9 ans il y a | 1

Charger plus