Answered

Inserting a row in a matrix in a precise place

z = sortrows([A; b], 1); [b_logical, b_where] = ismember(b, z, 'rows')

Inserting a row in a matrix in a precise place

z = sortrows([A; b], 1); [b_logical, b_where] = ismember(b, z, 'rows')

11 days ago | 1

Answered

Extract variable rows and columns from a matrix

A(sub2ind([nr, nc], rows, 1:nc))

Extract variable rows and columns from a matrix

A(sub2ind([nr, nc], rows, 1:nc))

12 days ago | 0

| accepted

Answered

How to make a NaN vector if there is a single NaN in a column?

[m, n] = size(A); A = nan(m, any(isnan(A(:))) * n)

How to make a NaN vector if there is a single NaN in a column?

[m, n] = size(A); A = nan(m, any(isnan(A(:))) * n)

12 days ago | 1

| accepted

Answered

How to assign values to an array with broadcasting

Your way of using repmat() is the easiest way.

How to assign values to an array with broadcasting

Your way of using repmat() is the easiest way.

12 days ago | 0

| accepted

Answered

Error using 'Save' including quotation marks around variables

Use writematrix() or dlmwrite() or csvwrite() for older versions bearing in mind that filename = 'sample'; % for example

Error using 'Save' including quotation marks around variables

Use writematrix() or dlmwrite() or csvwrite() for older versions bearing in mind that filename = 'sample'; % for example

12 days ago | 0

Answered

Find out how long after division will be an integer?

Simple use *mod()* doc mod

Find out how long after division will be an integer?

Simple use *mod()* doc mod

12 days ago | 0

Answered

How can one create frequency table of two dimensional data?

[u, ~, c] = unique(data, 'rows', 'stable'); Wanted = [u, accumarray(c, 1)]

How can one create frequency table of two dimensional data?

[u, ~, c] = unique(data, 'rows', 'stable'); Wanted = [u, accumarray(c, 1)]

12 days ago | 0

| accepted

Answered

how to skip plot in the legend when the number of plots is variable

<https://www.mathworks.com/help/matlab/ref/legend.html#bu_sz6u-1>

how to skip plot in the legend when the number of plots is variable

<https://www.mathworks.com/help/matlab/ref/legend.html#bu_sz6u-1>

12 days ago | 0

Answered

How to pad cell w/ multiple arrays with zeros

M = max(cellfun(@length, myCell)); Wanted = cellfun(@(x) [x; zeros(M - numel(x), 1)], myCell, 'un', 0)

How to pad cell w/ multiple arrays with zeros

M = max(cellfun(@length, myCell)); Wanted = cellfun(@(x) [x; zeros(M - numel(x), 1)], myCell, 'un', 0)

13 days ago | 0

| accepted

Answered

How do I take one matrix, divide by another, to make a bunch of new matrices with the dimension of the original matrix, but each scaled by each element of the second matrix?

Wanted = matrix ./ reshape(scalar, 1, 1, []) % use bsxfun() for older versions for dividing

How do I take one matrix, divide by another, to make a bunch of new matrices with the dimension of the original matrix, but each scaled by each element of the second matrix?

Wanted = matrix ./ reshape(scalar, 1, 1, []) % use bsxfun() for older versions for dividing

14 days ago | 1

| accepted

Answered

print values of array greater than 0

Just use > to find values greater than 0. doc > Hope you’re not bleeding :(

print values of array greater than 0

Just use > to find values greater than 0. doc > Hope you’re not bleeding :(

14 days ago | 0

| accepted

Answered

What frustrates you about MATLAB? #2

If find() operates along dimensions would make things a lot easier.

What frustrates you about MATLAB? #2

If find() operates along dimensions would make things a lot easier.

14 days ago | 1

Answered

Undefined function 'fit' for input arguments of type 'double'.

You don’t have the license for it.

Undefined function 'fit' for input arguments of type 'double'.

You don’t have the license for it.

14 days ago | 0

Answered

convert xi to i

ix = ismember(cell_array, 'x1') % strcmp() Wanted = ix + 2 * ~ix

convert xi to i

ix = ismember(cell_array, 'x1') % strcmp() Wanted = ix + 2 * ~ix

14 days ago | 0

Answered

Index each row of one matrix applying an operator/function to the second matrix, then concatenate all the results.

z = reshape(a(1:2),1,1,[]) + b; z1 = squeeze(num2cell(z,[1,2])); Wanted = cat(1, z1{:})

Index each row of one matrix applying an operator/function to the second matrix, then concatenate all the results.

z = reshape(a(1:2),1,1,[]) + b; z1 = squeeze(num2cell(z,[1,2])); Wanted = cat(1, z1{:})

15 days ago | 0

| accepted

Answered

Deleting an Element Modifies Other Elements

a=sym(1e-3:1e-4:2e-3); a(1)=[]; b=sym(1.1e-3:1e-4:2e-3);

Deleting an Element Modifies Other Elements

a=sym(1e-3:1e-4:2e-3); a(1)=[]; b=sym(1.1e-3:1e-4:2e-3);

15 days ago | 0

Answered

size Inputs must be scalar

B = zeros(numel(x), numel(y), numel(z)); % error is gone but I have no idea what’s going on

size Inputs must be scalar

B = zeros(numel(x), numel(y), numel(z)); % error is gone but I have no idea what’s going on

15 days ago | 0

| accepted

Answered

Comparing Matrices of Differing Dimensions, and Creating a New Matrix which meets a criteria

B(all(A(:) < B)) = []

Comparing Matrices of Differing Dimensions, and Creating a New Matrix which meets a criteria

B(all(A(:) < B)) = []

15 days ago | 0

| accepted

Answered

how to read day of the year as datetime ?

v = regexprep(""+vector,'(\d{4})(\d+)','00/$2/$1'); Wanted = datetime(datestr(v))

how to read day of the year as datetime ?

v = regexprep(""+vector,'(\d{4})(\d+)','00/$2/$1'); Wanted = datetime(datestr(v))

15 days ago | 0

Answered

Finding the max of column 2 and column 3

[matrix, max(of second and third column of the matrix along rows)]

Finding the max of column 2 and column 3

[matrix, max(of second and third column of the matrix along rows)]

16 days ago | 0

| accepted

Answered

How can one create this matrix, part 2

[X, Y, Z] = ndgrid(0:.1:0.5); [Z(:), Y(:), X(:)]

How can one create this matrix, part 2

[X, Y, Z] = ndgrid(0:.1:0.5); [Z(:), Y(:), X(:)]

16 days ago | 0

| accepted

Answered

How can one create this matrix?

[X, Y] = meshgrid(1:5); [X(:), Y(:)]

How can one create this matrix?

[X, Y] = meshgrid(1:5); [X(:), Y(:)]

16 days ago | 0

| accepted

Answered

New install: Undefined function 'isstring' for input arguments of type 'char'.

<https://www.mathworks.com/help/matlab/ref/isstring.html#bu6eyse_seealso> Release version *2016b*

New install: Undefined function 'isstring' for input arguments of type 'char'.

<https://www.mathworks.com/help/matlab/ref/isstring.html#bu6eyse_seealso> Release version *2016b*

16 days ago | 0

Answered

Create a Matrix from different ccella array.

m = cellfun(@size, data, 'un', 0); M = max(cat(1, m{:})); Data = cellfun(@(x) [x; nan(M(1) - size(x, 1), M(2))], data, '...

Create a Matrix from different ccella array.

m = cellfun(@size, data, 'un', 0); M = max(cat(1, m{:})); Data = cellfun(@(x) [x; nan(M(1) - size(x, 1), M(2))], data, '...

16 days ago | 0