Beantwortet
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 ...

etwa 9 Jahre vor | 0

| akzeptiert

Beantwortet
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 ...

etwa 9 Jahre vor | 0

| akzeptiert

Beantwortet
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.'...

etwa 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

etwa 9 Jahre vor | 1

| akzeptiert

Beantwortet
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...

etwa 9 Jahre vor | 0

Beantwortet
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); ...

etwa 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

mehr als 9 Jahre vor | 2

Beantwortet
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...

mehr als 9 Jahre vor | 1

| akzeptiert

Beantwortet
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))...

mehr als 9 Jahre vor | 1

Gesendet


padcatcell
concatenate cell arrays of unequal lengths

mehr als 9 Jahre vor | 88 Downloads |

0.0 / 5

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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')

mehr als 9 Jahre vor | 0

Beantwortet
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 ...

mehr als 9 Jahre vor | 0

Beantwortet
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> ...

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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)

mehr als 9 Jahre vor | 2

| akzeptiert

Beantwortet
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...

mehr als 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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)

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 0

| akzeptiert

Beantwortet
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,...

mehr als 9 Jahre vor | 6

| akzeptiert

Beantwortet
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, ...

mehr als 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

mehr als 9 Jahre vor | 0

Beantwortet
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)]...

mehr als 9 Jahre vor | 0

| akzeptiert

Beantwortet
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,...

mehr als 9 Jahre vor | 0

Beantwortet
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...

mehr als 9 Jahre vor | 1

Mehr laden