Risposto

create a matrix from a matrix x=[-2 -1 0 1 2]; which follow quadratic equations

x = [-2:2]; y = [2:-1:0]; bsxfun(@power, x', y)

create a matrix from a matrix x=[-2 -1 0 1 2]; which follow quadratic equations

x = [-2:2]; y = [2:-1:0]; bsxfun(@power, x', y)

quasi 8 anni fa | 0

| accettato

Risposto

How to break a number down into 4 squares

Such a breakdown (each output number should be at most the half of the previous one) does not always exist, take |23| for exampl...

How to break a number down into 4 squares

Such a breakdown (each output number should be at most the half of the previous one) does not always exist, take |23| for exampl...

quasi 8 anni fa | 1

Risposto

Saving function variables without evil eval

How about having all these state variables in a struct in the first place? Then you can save them to a mat file, for example: ...

Saving function variables without evil eval

How about having all these state variables in a struct in the first place? Then you can save them to a mat file, for example: ...

quasi 8 anni fa | 0

Risposto

Plot will not work

|nums(1,2)| is one particular element in your |nums| array, hence |t| will be |1|, and you'll end up plotting a single point.

Plot will not work

|nums(1,2)| is one particular element in your |nums| array, hence |t| will be |1|, and you'll end up plotting a single point.

quasi 8 anni fa | 0

| accettato

Risposto

How to creat a four dimentional (from a vector) matrix and reset it's 'lower triangle'

<https://uk.mathworks.com/help/matlab/ref/permute.html permute>

How to creat a four dimentional (from a vector) matrix and reset it's 'lower triangle'

<https://uk.mathworks.com/help/matlab/ref/permute.html permute>

quasi 8 anni fa | 0

Risposto

I am getting error with"Matrix dimensions must agree" for following code,please let me know where I am doing wrong?

The problem is here: k3/Qc Looks like |Qc| gets its value from global variable |u| which seems to be a non-scalar. So it...

I am getting error with"Matrix dimensions must agree" for following code,please let me know where I am doing wrong?

The problem is here: k3/Qc Looks like |Qc| gets its value from global variable |u| which seems to be a non-scalar. So it...

quasi 8 anni fa | 0

| accettato

Risposto

Hi, I wanted to get a quick look over for my program see if there were any flaws.. I think it's complete. specifications and program in link thanks..

The random sample comes from a normal instead of a uniform sample (assuming U stands for uniform). Also all the data you generat...

Hi, I wanted to get a quick look over for my program see if there were any flaws.. I think it's complete. specifications and program in link thanks..

The random sample comes from a normal instead of a uniform sample (assuming U stands for uniform). Also all the data you generat...

quasi 8 anni fa | 0

| accettato

Risposto

Replacing small sections of a logical vector

There are a few different ways to do it. This method may be frowned upon, but it nonetheless produces the required output: ...

Replacing small sections of a logical vector

There are a few different ways to do it. This method may be frowned upon, but it nonetheless produces the required output: ...

quasi 8 anni fa | 0

Risposto

Plot based on bins with binary data

This would do the trick if you bin them from |0| to |max(stimDuration)|: n = 2; % number of bins bar(splitapply(@(x) sum...

Plot based on bins with binary data

This would do the trick if you bin them from |0| to |max(stimDuration)|: n = 2; % number of bins bar(splitapply(@(x) sum...

quasi 8 anni fa | 1

| accettato

Risposto

question on using parfor

The error message refers to the variable classification when using parfor: <https://uk.mathworks.com/help/distcomp/classificatio...

question on using parfor

The error message refers to the variable classification when using parfor: <https://uk.mathworks.com/help/distcomp/classificatio...

quasi 8 anni fa | 1

| accettato

Risposto

Boolen logic operations between integer numbers

>> logical(3) ans = 1 >> logical(-4) ans = 1 So 1 && 1 = 1, according to the <https://uk.mat...

Boolen logic operations between integer numbers

>> logical(3) ans = 1 >> logical(-4) ans = 1 So 1 && 1 = 1, according to the <https://uk.mat...

quasi 8 anni fa | 1

| accettato

Risposto

Finding sum of all the elements in a row corresponding to an element which is less than a certain value?

a = [1 0 3; 9 1 5; 6 0 9; 2 4 6; 5 2 0]; sum(sum( a(a(:,1)<3, 2:3) )) a(:,1)<3 created a binary vector to indicate which...

Finding sum of all the elements in a row corresponding to an element which is less than a certain value?

a = [1 0 3; 9 1 5; 6 0 9; 2 4 6; 5 2 0]; sum(sum( a(a(:,1)<3, 2:3) )) a(:,1)<3 created a binary vector to indicate which...

quasi 8 anni fa | 1

| accettato

Risposto

Cut differently odd and even rows in matrix

n = size(a, 2); % number of columns a(1:2:n,:) = a(1:2:n,[[3:n],[1:2]]); % move first 2 elements in odd rows to the end ...

Cut differently odd and even rows in matrix

n = size(a, 2); % number of columns a(1:2:n,:) = a(1:2:n,[[3:n],[1:2]]); % move first 2 elements in odd rows to the end ...

quasi 8 anni fa | 0

| accettato

Risposto

How to convert a 3x3xN matrix to a N element cell array?

% a is your 3*3*N array c = mat2cell(a,3,3,ones(1,N)); c = c(:);

How to convert a 3x3xN matrix to a N element cell array?

% a is your 3*3*N array c = mat2cell(a,3,3,ones(1,N)); c = c(:);

quasi 8 anni fa | 1

| accettato

Risposto

Problems running a function in a for loop and dynamically assigning to a struct

Thought I'd add an 'Answer' to make this question 'answered' instead of the comments. The loop fails eventually due to the HF...

Problems running a function in a for loop and dynamically assigning to a struct

Thought I'd add an 'Answer' to make this question 'answered' instead of the comments. The loop fails eventually due to the HF...

quasi 8 anni fa | 1

| accettato

Risposto

Undefined function 'mtimes' for input arguments of type 'struct'.

This gave me a different error in the first loop: Undefined operator '+' for input arguments of type 'struct'. Which is ...

Undefined function 'mtimes' for input arguments of type 'struct'.

This gave me a different error in the first loop: Undefined operator '+' for input arguments of type 'struct'. Which is ...

quasi 8 anni fa | 0

Risposto

How to access specific rows (or columns) of a file data without loading all data?

If you're using a .mat file and 'rows (or columns)' refer to an array stored in that file, then the doc helps: <https://uk.math...

How to access specific rows (or columns) of a file data without loading all data?

If you're using a .mat file and 'rows (or columns)' refer to an array stored in that file, then the doc helps: <https://uk.math...

quasi 8 anni fa | 0

Risposto

Generating a random symmetric matrix

A = randi(2,N,N) - 1; A = A - tril(A,-1) + triu(A,1)'; This will copy the upper triangle to the lower triangle.

Generating a random symmetric matrix

A = randi(2,N,N) - 1; A = A - tril(A,-1) + triu(A,1)'; This will copy the upper triangle to the lower triangle.

quasi 8 anni fa | 4

| accettato

Risposto

How to combine the name of struct together

Data.(k)(i).somethingelse = your_value See the <http://uk.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-va...

How to combine the name of struct together

Data.(k)(i).somethingelse = your_value See the <http://uk.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-va...

quasi 8 anni fa | 1

| accettato

Risposto

Error using table (line 253)

Did you check how Mode looks like? It is a row array with 2 elements, which is not compatible with the 3-element column vectors ...

Error using table (line 253)

Did you check how Mode looks like? It is a row array with 2 elements, which is not compatible with the 3-element column vectors ...

quasi 8 anni fa | 0

Risposto

Minimum in a matrix! and its location

There is no need to loop through the rows, you can specify the 'by-dimension' minimum like this: a = [ 1 2 3 0; 7 5 4 6; 9 ...

Minimum in a matrix! and its location

There is no need to loop through the rows, you can specify the 'by-dimension' minimum like this: a = [ 1 2 3 0; 7 5 4 6; 9 ...

quasi 8 anni fa | 1

| accettato

Risposto

random vector containing zero and values

A(1:6)=0; N = 6; b = randi(N); C =(1:b); A_idx = randperm(N, b); % generate b random integers from 1 to N C_idx = randper...

random vector containing zero and values

A(1:6)=0; N = 6; b = randi(N); C =(1:b); A_idx = randperm(N, b); % generate b random integers from 1 to N C_idx = randper...

quasi 8 anni fa | 1

Risposto

Convert contents of array into index

Your first code should work. l = ones(1, 10000); % make sure this is bigger than the largest index col will specify col ...

Convert contents of array into index

Your first code should work. l = ones(1, 10000); % make sure this is bigger than the largest index col will specify col ...

quasi 8 anni fa | 0

| accettato

Risposto

Subscript indices must either be real positive integers or logicals.

F= ... b3(X-x(1)) ... A '*' is missing: F= ... b3*(X-x(1))...

Subscript indices must either be real positive integers or logicals.

F= ... b3(X-x(1)) ... A '*' is missing: F= ... b3*(X-x(1))...

quasi 8 anni fa | 1

Risposto

Updating of new Matlab software

Same question <https://uk.mathworks.com/matlabcentral/answers/307321-can-i-uninstall-matlab-2016a-after-installing-matlab-2016b?...

Updating of new Matlab software

Same question <https://uk.mathworks.com/matlabcentral/answers/307321-can-i-uninstall-matlab-2016a-after-installing-matlab-2016b?...

quasi 8 anni fa | 0

Risposto

Inner matrix dimensions must agree

4*(0.985)*(5.67*10.^-8)*(TS).^3*(TT) Here according to the <https://uk.mathworks.com/help/matlab/matlab_prog/operator-prece...

Inner matrix dimensions must agree

4*(0.985)*(5.67*10.^-8)*(TS).^3*(TT) Here according to the <https://uk.mathworks.com/help/matlab/matlab_prog/operator-prece...

quasi 8 anni fa | 0

Risposto

Filter table data by character string

November = data(11 == month(data.date),:)

Filter table data by character string

November = data(11 == month(data.date),:)

quasi 8 anni fa | 0

| accettato

Risposto

find probability of number in a matrix

You can sum all elements in each column that matches, and divide by the number of nonzero elements: v = (1:4)'; % your numb...

find probability of number in a matrix

You can sum all elements in each column that matches, and divide by the number of nonzero elements: v = (1:4)'; % your numb...

quasi 8 anni fa | 0

| accettato

Risposto

store value after multiple loops

Storing results in a multidimensional array: results = zeros(T, T, T, T); % your code below for n1=1:T x=xi(n1); ...

store value after multiple loops

Storing results in a multidimensional array: results = zeros(T, T, T, T); % your code below for n1=1:T x=xi(n1); ...

quasi 8 anni fa | 0

Risposto

How do I change a whole row/column to zero in a matrix relating to a 'greater than' condition.

> But is there an easier, more automatic way where I could say if a value in U is greater than 5 then change the corresponding c...

How do I change a whole row/column to zero in a matrix relating to a 'greater than' condition.

> But is there an easier, more automatic way where I could say if a value in U is greater than 5 then change the corresponding c...

quasi 8 anni fa | 0