Answered

is the mean function broken in R2014b

You probably created a variable named _mean_, and are accidentally trying to access that variable. I suggest either doing ...

is the mean function broken in R2014b

You probably created a variable named _mean_, and are accidentally trying to access that variable. I suggest either doing ...

1 day ago | 1

| accepted

Answered

My cell array has 861 rows and each row has vectors of varying sizes. I want to calculate std dev only for cells that have 20 elements. Others should give a value of 0. How do I tell cellfun to get only the cells with 20 elements. Here is my attempt

ratios = {rand(19,1); rand(20,1); rand(21,1)} cellfun(@(x)std(x)*(numel(x)==20),ratios)

My cell array has 861 rows and each row has vectors of varying sizes. I want to calculate std dev only for cells that have 20 elements. Others should give a value of 0. How do I tell cellfun to get only the cells with 20 elements. Here is my attempt

ratios = {rand(19,1); rand(20,1); rand(21,1)} cellfun(@(x)std(x)*(numel(x)==20),ratios)

2 days ago | 0

| accepted

Answered

What is algorithm used in rangesearch function in matlab

There are typically two places to look for algorithm references for MATLAB function: # The documentation page for that functi...

What is algorithm used in rangesearch function in matlab

There are typically two places to look for algorithm references for MATLAB function: # The documentation page for that functi...

3 days ago | 0

Answered

Hi,How to plot vectors with different sizes against each other ? size of one vector is 24244x1 and other vector is 24243x1

The correct way to do this depends on how the two vectors relate to each other. Take a smaller example. Suppose my two vectors a...

Hi,How to plot vectors with different sizes against each other ? size of one vector is 24244x1 and other vector is 24243x1

The correct way to do this depends on how the two vectors relate to each other. Take a smaller example. Suppose my two vectors a...

3 days ago | 1

Answered

max repetitive values in a vector

I think this does what you want A= [ 2 3 3 4; 4 4 3 6; 5 3 3 9; 2 4 3 8; 8 3 3 12; ...

max repetitive values in a vector

I think this does what you want A= [ 2 3 3 4; 4 4 3 6; 5 3 3 9; 2 4 3 8; 8 3 3 12; ...

4 days ago | 1

| accepted

Answered

Example file from Mathworks does not exist

Do you have the <https://www.mathworks.com/help/audio/index.html Audio System Toolbox> installed? Type <https://www.mathworks...

Example file from Mathworks does not exist

Do you have the <https://www.mathworks.com/help/audio/index.html Audio System Toolbox> installed? Type <https://www.mathworks...

5 days ago | 0

Answered

Creating points inside polygon boundary?

I would use the <https://en.wikipedia.org/wiki/Rejection_sampling rejection method>. Define a square that encloses the entire po...

Creating points inside polygon boundary?

I would use the <https://en.wikipedia.org/wiki/Rejection_sampling rejection method>. Define a square that encloses the entire po...

6 days ago | 1

Answered

How to find the inverse of a 2x2 matrix using gaussian elimination (not using rref or lu)?

I found <https://www.mathworks.com/matlabcentral/answers/130593-hi-am-working-on-a-code-for-gaussian-elimination this answer> by...

How to find the inverse of a 2x2 matrix using gaussian elimination (not using rref or lu)?

I found <https://www.mathworks.com/matlabcentral/answers/130593-hi-am-working-on-a-code-for-gaussian-elimination this answer> by...

6 days ago | 0

Answered

This code is working but in every run i am getting different value of x(1),x(2) and x(3)..kindly solve this problem...its very urgent

Simulated annealing uses randomness as part of the algorithm. If you set the random seed before this code, for example with the ...

This code is working but in every run i am getting different value of x(1),x(2) and x(3)..kindly solve this problem...its very urgent

Simulated annealing uses randomness as part of the algorithm. If you set the random seed before this code, for example with the ...

7 days ago | 0

Answered

Add command disponible in Matlab2017b in my matlab2017a?

I would <https://www.mathworks.com/support/contact_us.html contact support> directly about this.

Add command disponible in Matlab2017b in my matlab2017a?

I would <https://www.mathworks.com/support/contact_us.html contact support> directly about this.

7 days ago | 0

Answered

How to find the efficiency of a function?

I'm not what you mean by "efficiency". Do you mean the time the program (or specific lines) take to execute? If so, then take a ...

How to find the efficiency of a function?

I'm not what you mean by "efficiency". Do you mean the time the program (or specific lines) take to execute? If so, then take a ...

7 days ago | 0

Answered

Why the function rainflow doesn't work in my MatlabR2017?

According to <https://www.mathworks.com/help/signal/ref/rainflow.html the documentation page for |*rainflow*|>, this command was...

Why the function rainflow doesn't work in my MatlabR2017?

According to <https://www.mathworks.com/help/signal/ref/rainflow.html the documentation page for |*rainflow*|>, this command was...

7 days ago | 0

| accepted

Answered

Is it possible to incorporate a hyperlink within a string array that references a specific variable while in a for loop

I haven't figured out what you were trying to do with the breaks, but the core functionality works if you use this: descrip...

Is it possible to incorporate a hyperlink within a string array that references a specific variable while in a for loop

I haven't figured out what you were trying to do with the breaks, but the core functionality works if you use this: descrip...

7 days ago | 0

Answered

Hello, how do I display the equation for a polyfit line on this plot?

Here is an example of how you can do this. There are more efficient ways (e.g. using polyval on both the min and max at the s...

Hello, how do I display the equation for a polyfit line on this plot?

Here is an example of how you can do this. There are more efficient ways (e.g. using polyval on both the min and max at the s...

7 days ago | 0

Answered

How to find the symmetric and skew symmetric part of a specified matrix?

A_sym = (A+A.')/2; A_anti = (A-A.')/2; The _.'_ operation is the <https://www.mathworks.com/help/matlab/ref/transpos...

How to find the symmetric and skew symmetric part of a specified matrix?

A_sym = (A+A.')/2; A_anti = (A-A.')/2; The _.'_ operation is the <https://www.mathworks.com/help/matlab/ref/transpos...

7 days ago | 0

| accepted

Answered

how to label y axis tick marks?

This code (which just combines your code) works fine for me: %load data data = [239 199 192 146 123 111 103]; labels ...

how to label y axis tick marks?

This code (which just combines your code) works fine for me: %load data data = [239 199 192 146 123 111 103]; labels ...

7 days ago | 0

| accepted

Answered

Normal distribution problem using histfit

If @dpb had made his comment as an answer, I would have upvoted it. Your data are clearly not normally distributed. Is there ...

Normal distribution problem using histfit

If @dpb had made his comment as an answer, I would have upvoted it. Your data are clearly not normally distributed. Is there ...

7 days ago | 0

| accepted

Answered

Is it possible to incorporate a hyperlink within a string array that references a specific variable while in a for loop

Your code will at least execute if you change names = ['bob' 'james' 'jim'] to names = {'bob' 'james' 'jim'} Is ...

Is it possible to incorporate a hyperlink within a string array that references a specific variable while in a for loop

Your code will at least execute if you change names = ['bob' 'james' 'jim'] to names = {'bob' 'james' 'jim'} Is ...

8 days ago | 0

Answered

How do you multiply two arrays with a for loop?

I think you want something like out = reshape(Array2,300,[]) .* Array1; Then you can use reshape again to bring it back ...

How do you multiply two arrays with a for loop?

I think you want something like out = reshape(Array2,300,[]) .* Array1; Then you can use reshape again to bring it back ...

8 days ago | 0

| accepted

Answered

How do I do addition on only the first two columns of an array?

I'm pretty confused by your question, and in particular how you are referring to your "columns" and "rows". I downloaded your M...

How do I do addition on only the first two columns of an array?

I'm pretty confused by your question, and in particular how you are referring to your "columns" and "rows". I downloaded your M...

8 days ago | 0

| accepted

Answered

How can I create cell arrays that are in sequential order?

Instead of using |num2str| to create the string, use <https://www.mathworks.com/help/matlab/ref/sprintf.html |*sprintf*|>. Fo...

How can I create cell arrays that are in sequential order?

Instead of using |num2str| to create the string, use <https://www.mathworks.com/help/matlab/ref/sprintf.html |*sprintf*|>. Fo...

8 days ago | 1

Answered

How do you bin data by a certain value? and count the values in each bin?

Use the <https://www.mathworks.com/help/matlab/ref/histcounts.html |*histcounts*|> command.

How do you bin data by a certain value? and count the values in each bin?

Use the <https://www.mathworks.com/help/matlab/ref/histcounts.html |*histcounts*|> command.

8 days ago | 0

Answered

Error while using plotyy function

Read the documentation for <https://www.mathworks.com/help/matlab/ref/plotyy.html |*plotyy*|> a bit more carefully. The first _f...

Error while using plotyy function

Read the documentation for <https://www.mathworks.com/help/matlab/ref/plotyy.html |*plotyy*|> a bit more carefully. The first _f...

8 days ago | 0

| accepted

Answered

How to identify k_j largest values for each column j of a matrix?

A = [ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 ...

How to identify k_j largest values for each column j of a matrix?

A = [ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 ...

8 days ago | 1

| accepted

Answered

Get the max value and indices of a fourth order tensor.

If _T_ is the array, then [M,idx] = max(T(:)) will give the maximum value and <https://www.mathworks.com/help/matlab/mat...

Get the max value and indices of a fourth order tensor.

If _T_ is the array, then [M,idx] = max(T(:)) will give the maximum value and <https://www.mathworks.com/help/matlab/mat...

8 days ago | 1

| accepted

Answered

Why Matlab only run the "else" function equation even "a" fulfils the condition in "if" function? The graph is plotted based on the equation in "else" function only no matter whether "a" is less than 198 or not.

The reason is that when you check a vector of condition, such as a=[0 200 400 600]; if a<198 then _all_ of the elemen...

Why Matlab only run the "else" function equation even "a" fulfils the condition in "if" function? The graph is plotted based on the equation in "else" function only no matter whether "a" is less than 198 or not.

The reason is that when you check a vector of condition, such as a=[0 200 400 600]; if a<198 then _all_ of the elemen...

8 days ago | 0

Answered

Create a list of means from a 3D matrix

M = rand(360,220,60); timeStepMean = nanmean(nanmean(M(:,2:end,:),1),2); You might then want to use the <https://www.mat...

Create a list of means from a 3D matrix

M = rand(360,220,60); timeStepMean = nanmean(nanmean(M(:,2:end,:),1),2); You might then want to use the <https://www.mat...

9 days ago | 0

Answered

For 2 curves, how to have xticks on both the above and below of x-axis?

The easiest way to get something _close_ to what you want is to use the <https://www.mathworks.com/help/matlab/ref/yyaxis.html |...

For 2 curves, how to have xticks on both the above and below of x-axis?

The easiest way to get something _close_ to what you want is to use the <https://www.mathworks.com/help/matlab/ref/yyaxis.html |...

10 days ago | 0

Answered

Consecutive number by using for loop?

This seems like homework. Even if it isn't, it seems like it would be more beneficial for you to learn about the MATLAB document...

Consecutive number by using for loop?

This seems like homework. Even if it isn't, it seems like it would be more beneficial for you to learn about the MATLAB document...

10 days ago | 0

Answered

Write a function in terms of another function

I think this does what you want F = @(x1,x2)(x1.^2 + x2.^2 + 2*x1.*x2) G = @(f)f.^2 Call this, for example, as G...

Write a function in terms of another function

I think this does what you want F = @(x1,x2)(x1.^2 + x2.^2 + 2*x1.*x2) G = @(f)f.^2 Call this, for example, as G...

10 days ago | 0