Answered

Add a row of zeros at the end of the matrix

output = [x' zeros(4,1)]; You can generalize this a bit by using the numel function to determine and use the size of x to get t...

Add a row of zeros at the end of the matrix

output = [x' zeros(4,1)]; You can generalize this a bit by using the numel function to determine and use the size of x to get t...

20 hours ago | 0

Answered

How can i merge 2 cells with different items

I would solve this by trying to use different MATLAB data types more effectively: str(1).item = {5,4,zeros(1,5)}; str(2).item ...

How can i merge 2 cells with different items

I would solve this by trying to use different MATLAB data types more effectively: str(1).item = {5,4,zeros(1,5)}; str(2).item ...

20 hours ago | 0

Answered

Getting started with machine learning

I believe the answers to your questions are yes yes yes in that order. One possible starting point is MATLAB for Machine Lea...

Getting started with machine learning

I believe the answers to your questions are yes yes yes in that order. One possible starting point is MATLAB for Machine Lea...

21 hours ago | 0

Answered

Cell to matrix average

I believe this does what you want: B = squeeze(mean(reshape(cell2mat(A),93,145,147,19)));

Cell to matrix average

I believe this does what you want: B = squeeze(mean(reshape(cell2mat(A),93,145,147,19)));

4 days ago | 0

Answered

Delete rows in intervall

If your vector is a multiple of 7 in length, then this will work: x = reshape(x,7,[]); x = x(1:4,:); x = x(:);

Delete rows in intervall

If your vector is a multiple of 7 in length, then this will work: x = reshape(x,7,[]); x = x(1:4,:); x = x(:);

4 days ago | 0

Answered

Bin data in a strange way

% Simulate some data data = [0; 0; -10; -2766; -5600; -5535]; % Define bin centers binCenter = [ 0, -2765, -5530, -8295, -...

Bin data in a strange way

% Simulate some data data = [0; 0; -10; -2766; -5600; -5535]; % Define bin centers binCenter = [ 0, -2765, -5530, -8295, -...

4 days ago | 0

| accepted

Answered

How to extract first non-zero element in each column and put into a new array

Here is one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; [m,n] = size(in); out = nan(1,n); for nc = 1:n ...

How to extract first non-zero element in each column and put into a new array

Here is one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; [m,n] = size(in); out = nan(1,n); for nc = 1:n ...

5 days ago | 0

Answered

How to extract first non-zero element in each column and put into a new array

Here is one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; mid = in; for nr = size(in,1)-1:-1:1 mid(nr,...

How to extract first non-zero element in each column and put into a new array

Here is one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; mid = in; for nr = size(in,1)-1:-1:1 mid(nr,...

5 days ago | 0

Answered

How to extract first non-zero element in each column and put into a new array

Here is a one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; [m,n] = size(in); [i,j] = find(in); [~,jj] =...

How to extract first non-zero element in each column and put into a new array

Here is a one way: in=[0 0 6 0 0 5; 1 3 5 1 0 4; 4 4 5 3 4 5]; [m,n] = size(in); [i,j] = find(in); [~,jj] =...

5 days ago | 0

Answered

for loop to create a vector V of the squares

Because this is a very basic MATLAB question, and you don't even know how to start, I would recommending watching the MATLAB Onr...

for loop to create a vector V of the squares

Because this is a very basic MATLAB question, and you don't even know how to start, I would recommending watching the MATLAB Onr...

5 days ago | 0

Answered

How do I determine which model fits my data the best?

The second output from the fit command gives goodness-of-fit statistics. You might also take a look at "Determing the Best Fit"...

How do I determine which model fits my data the best?

The second output from the fit command gives goodness-of-fit statistics. You might also take a look at "Determing the Best Fit"...

5 days ago | 0

Answered

Plotting circles in a for loop using a time step

Your code runs fine for me, and creates a figure. What's the problem? What's your question? I'm going to take a stab at an answ...

Plotting circles in a for loop using a time step

Your code runs fine for me, and creates a figure. What's the problem? What's your question? I'm going to take a stab at an answ...

5 days ago | 0

Answered

Find the cell index in a nested cell array, corresponding to a string (by using strcmp)

Here is a one-liner: cellfun(@(y)any(any(cellfun(@(x)isequal(x,{'BLUE'}),y))),A) I stumbled across this function for dealing w...

Find the cell index in a nested cell array, corresponding to a string (by using strcmp)

Here is a one-liner: cellfun(@(y)any(any(cellfun(@(x)isequal(x,{'BLUE'}),y))),A) I stumbled across this function for dealing w...

5 days ago | 0

Answered

sorting matrix in ascending order based on column 1 (and ascending order also for column 2)

Use the sortrows command. B = sortrows(A,1);

sorting matrix in ascending order based on column 1 (and ascending order also for column 2)

Use the sortrows command. B = sortrows(A,1);

7 days ago | 0

| accepted

Answered

How do I create a 1x21 matrix where the inputs are all the different values of d

Does this code do what you had intended? (There was some guesswork on my part.) B=[1 2 3 4 5 6 7; 9 11 13 15 17 19 21]; Norm...

How do I create a 1x21 matrix where the inputs are all the different values of d

Does this code do what you had intended? (There was some guesswork on my part.) B=[1 2 3 4 5 6 7; 9 11 13 15 17 19 21]; Norm...

7 days ago | 0

| accepted

Answered

Reading through folders getting the warning : ." Index in position 1 exceeds array bounds (must not exceed 1).".

At some point, did you define a variable named dir? MATLAB would then try to access that variable, rather than the command. Clea...

Reading through folders getting the warning : ." Index in position 1 exceeds array bounds (must not exceed 1).".

At some point, did you define a variable named dir? MATLAB would then try to access that variable, rather than the command. Clea...

7 days ago | 0

| accepted

Answered

Plotting within a nested for loop

I'm guessing you wanted something like plot(x2,y,'.') or possibly plot(x2,y)

Plotting within a nested for loop

I'm guessing you wanted something like plot(x2,y,'.') or possibly plot(x2,y)

8 days ago | 0

Answered

How can I count the largest number of repeated numbers in a double?

I recommend downloading the RunLength utility from the File Exchange.

How can I count the largest number of repeated numbers in a double?

I recommend downloading the RunLength utility from the File Exchange.

8 days ago | 0

Answered

What is difference between isequal and == in comparing two vectors

isequal will return a single logical value, indicating whether or not the two vectors are identical. == will give a vector with...

What is difference between isequal and == in comparing two vectors

isequal will return a single logical value, indicating whether or not the two vectors are identical. == will give a vector with...

8 days ago | 3

Answered

how to create a for loop 380:780?

I would use a cell array, not variable names that also encode an index: for ic = 380:780 CM4{ic} = spec_data(spec_data.wav...

how to create a for loop 380:780?

I would use a cell array, not variable names that also encode an index: for ic = 380:780 CM4{ic} = spec_data(spec_data.wav...

8 days ago | 0

| accepted

Answered

Confidence interval in Linear Regression

I'm curious why you want to code them from scratch, but the formulas for the standard errors and confidence intervals for the sl...

Confidence interval in Linear Regression

I'm curious why you want to code them from scratch, but the formulas for the standard errors and confidence intervals for the sl...

8 days ago | 0

Answered

find possible combinations of each row of matrix and allocate their respective values into 2 different matrices

% The input data A = [0.3939 0.3116]; B = [1 16 17 6 9 0 0 0 0 0 0 0 0 0 1 16 17 6 7 8 10 0 0 0 0 0 0 0 ]; ...

find possible combinations of each row of matrix and allocate their respective values into 2 different matrices

% The input data A = [0.3939 0.3116]; B = [1 16 17 6 9 0 0 0 0 0 0 0 0 0 1 16 17 6 7 8 10 0 0 0 0 0 0 0 ]; ...

9 days ago | 0

| accepted

Answered

Is it possible to draw a bar plot with percentage lines?

I'm not sure if you are asking for them to be automatically positioned, but there are many options for drawing lines on a plot: ...

Is it possible to draw a bar plot with percentage lines?

I'm not sure if you are asking for them to be automatically positioned, but there are many options for drawing lines on a plot: ...

9 days ago | 1

Answered

Having trouble getting legend to display properly

One possibility is to set the 'Visible' property of those axes to 'off'. Here is a simpler example ... figure plot(magic(3)) ...

Having trouble getting legend to display properly

One possibility is to set the 'Visible' property of those axes to 'off'. Here is a simpler example ... figure plot(magic(3)) ...

9 days ago | 0

Answered

How to shorten my data in the struct I have?

The problem is that you are trying to resize your variable "in place". You can't really do this in pieces. One solution would b...

How to shorten my data in the struct I have?

The problem is that you are trying to resize your variable "in place". You can't really do this in pieces. One solution would b...

10 days ago | 1

| accepted

Answered

Sensitivity-Specificity of clustering result (no labeled data)

I was really tempted to just write the one-word answer, "No". But, instead I'll say that I just don't see how it could be possi...

Sensitivity-Specificity of clustering result (no labeled data)

I was really tempted to just write the one-word answer, "No". But, instead I'll say that I just don't see how it could be possi...

10 days ago | 0

Answered

how do I get the values of a matrix using movsum to add 90 consectuive cells in the matrix?

This task will be trivial if you use the RunLength utility from the File Exchange.

how do I get the values of a matrix using movsum to add 90 consectuive cells in the matrix?

This task will be trivial if you use the RunLength utility from the File Exchange.

11 days ago | 0

| accepted

Answered

Fill an array over an iteration

Does using BBB(i,:)=Dstop instead of BBB(i,:)=B(:) do what you want? If not, you need to explain a bit more.

Fill an array over an iteration

Does using BBB(i,:)=Dstop instead of BBB(i,:)=B(:) do what you want? If not, you need to explain a bit more.

11 days ago | 0

| accepted