Data scientist at Cohen Veterans Bioscience; Obsessive runner. Professional Interests: Predictive modeling, statistics. (I don't respond to email via author page, but will usually look at a question if you send me a link to it.)

Answered

getting numbers from a cell

A = '1.39675e-02 -2.58099e-01 -8.32728e-03 0.00000e+00 2.19518e+01 1.21930e-01 0.00000e+00 3.00000e-05 3.00000e+02 9.9820...

getting numbers from a cell

A = '1.39675e-02 -2.58099e-01 -8.32728e-03 0.00000e+00 2.19518e+01 1.21930e-01 0.00000e+00 3.00000e-05 3.00000e+02 9.9820...

5 hours ago | 0

| accepted

Answered

Array element rearrange without using conditional statement?

I don't get the same output you specify, but I think I obeyed your rules. Did I make a mistake, or did you? Regardless, maybe y...

Array element rearrange without using conditional statement?

I don't get the same output you specify, but I think I obeyed your rules. Did I make a mistake, or did you? Regardless, maybe y...

1 day ago | 0

Answered

I put an if loop inside a function and it doesn't work. It doesn't work with any loop or anything I try to add like a sub-function.

Because a is a vector, the if statement if a == 0 ... end will only be entered if a==0 for all elements of a. An if stat...

I put an if loop inside a function and it doesn't work. It doesn't work with any loop or anything I try to add like a sub-function.

Because a is a vector, the if statement if a == 0 ... end will only be entered if a==0 for all elements of a. An if stat...

2 days ago | 0

Answered

Non-linear regression

It seems to me that your two models are equivalent, but one is specified in a way that masks that fact. x0 is really just a sca...

Non-linear regression

It seems to me that your two models are equivalent, but one is specified in a way that masks that fact. x0 is really just a sca...

2 days ago | 0

Answered

Find indices of column/row in double that have matching value

Sounds like you could use either the find or ismember command.

Find indices of column/row in double that have matching value

Sounds like you could use either the find or ismember command.

2 days ago | 0

| accepted

Answered

How to shift all the non-zero elements of a matrix to the right of the matrix?

% The original data M = [1 2 3 0 0 1 2 0 0 0 1 2 3 0 0 0 1 0 0 1 2 3 1 2]; % Preallocate the matrix (which also ...

How to shift all the non-zero elements of a matrix to the right of the matrix?

% The original data M = [1 2 3 0 0 1 2 0 0 0 1 2 3 0 0 0 1 0 0 1 2 3 1 2]; % Preallocate the matrix (which also ...

2 days ago | 2

Answered

Difference between a for loop and a while loop (in the context of programming experiments if that adds)

As a general rule, use a for loop when you know exactly how many iterations you need: for m = 1:10 ... end Use a while lo...

Difference between a for loop and a while loop (in the context of programming experiments if that adds)

As a general rule, use a for loop when you know exactly how many iterations you need: for m = 1:10 ... end Use a while lo...

2 days ago | 0

| accepted

Answered

I have a code and it keep saying "invalid expression. when calling a function or indexing a variable, use parentheses. otherwise check for mismatched delimiters.

This line is where the problem is ... [A, B] = equationsToMatrix([eq1, eq2, eq3, [i1, i2, i3]); Inside the parentheses, you ha...

I have a code and it keep saying "invalid expression. when calling a function or indexing a variable, use parentheses. otherwise check for mismatched delimiters.

This line is where the problem is ... [A, B] = equationsToMatrix([eq1, eq2, eq3, [i1, i2, i3]); Inside the parentheses, you ha...

4 days ago | 0

| accepted

Answered

Problem with radians and degrees

You need parentheses around 2*n. Otherwise, MATLAB will divide by 2, then multiply by n. % Chebshevy Poles clc clear ...

Problem with radians and degrees

You need parentheses around 2*n. Otherwise, MATLAB will divide by 2, then multiply by n. % Chebshevy Poles clc clear ...

8 days ago | 0

| accepted

Answered

How to take positive value from logical command

I'm not sure I know what you mean. Do you mean you only want true if both the following criteria are met? A > B A > 0 If that...

How to take positive value from logical command

I'm not sure I know what you mean. Do you mean you only want true if both the following criteria are met? A > B A > 0 If that...

8 days ago | 2

| accepted

Answered

Why do I get an error in this function and how to solve it?

You cannot define a function at the command line. You need to place the lines function r=OU_SAMPLE (n,dt,beta,theta,sig,r0); t...

Why do I get an error in this function and how to solve it?

You cannot define a function at the command line. You need to place the lines function r=OU_SAMPLE (n,dt,beta,theta,sig,r0); t...

9 days ago | 0

| accepted

Answered

Change value to NaN element

Here is one way: % The original data A = [NaN,NaN,NaN,NaN,NaN,1,5,7,9,NaN,NaN,NaN,NaN,5,5,53,3,NaN,NaN]; % The indices of t...

Change value to NaN element

Here is one way: % The original data A = [NaN,NaN,NaN,NaN,NaN,1,5,7,9,NaN,NaN,NaN,NaN,5,5,53,3,NaN,NaN]; % The indices of t...

10 days ago | 0

| accepted

Answered

How can I plot average and then the error bar with standard deviation?

You can use the errorbar function.

How can I plot average and then the error bar with standard deviation?

You can use the errorbar function.

10 days ago | 0

Answered

Finding correct row in array with multiple columns matching different conditions

A = [1 2 3; 4 5 6]; % 2 rows and 3 columns B = [1 1 2; 1 2 3; 2 2 4; 3 4 5; 4 5 6]; % 5 rows and ...

Finding correct row in array with multiple columns matching different conditions

A = [1 2 3; 4 5 6]; % 2 rows and 3 columns B = [1 1 2; 1 2 3; 2 2 4; 3 4 5; 4 5 6]; % 5 rows and ...

12 days ago | 0

Answered

How to properly use nargin

When you tried to call it like this: y = estimate_pi_Leibniz_Clark_Brendan(N) the problem is that in the calling workspace, th...

How to properly use nargin

When you tried to call it like this: y = estimate_pi_Leibniz_Clark_Brendan(N) the problem is that in the calling workspace, th...

12 days ago | 1

| accepted

Answered

Error: "In an assignment A(I) = B, the number of elements in B and I must be the same." error

You defined the global variable ii, but never assigned it a value. Therefore, it is an empty array. Therefore d1 is also an emp...

Error: "In an assignment A(I) = B, the number of elements in B and I must be the same." error

You defined the global variable ii, but never assigned it a value. Therefore, it is an empty array. Therefore d1 is also an emp...

13 days ago | 0

| accepted

Answered

How to reduce space between plots in subplot and how to increase the area of plot in subplot

This might require an overhaul of your code, but I would say you can probably achieve better results with the new(er) tiledlayou...

How to reduce space between plots in subplot and how to increase the area of plot in subplot

This might require an overhaul of your code, but I would say you can probably achieve better results with the new(er) tiledlayou...

14 days ago | 0

Answered

Correlation between several variables

I think I would use the corrcoef function: [r,p] = corrcoef(Data); and just focus on the last column of the r and p outputs, w...

Correlation between several variables

I think I would use the corrcoef function: [r,p] = corrcoef(Data); and just focus on the last column of the r and p outputs, w...

14 days ago | 0

| accepted

Answered

How do I return The Average of particular row incriment in a vector?

A = [1 1 1 2 2 2 5 5 8]; n = 3; B = mean(reshape(A,n,[]))

How do I return The Average of particular row incriment in a vector?

A = [1 1 1 2 2 2 5 5 8]; n = 3; B = mean(reshape(A,n,[]))

15 days ago | 1

Answered

How do you get a specific decimal accuracy with the fprintf function?

Your r variable needs to be a second argument (not using a plus sign as you did). r = pi; fprintf("The estimated principle st...

How do you get a specific decimal accuracy with the fprintf function?

Your r variable needs to be a second argument (not using a plus sign as you did). r = pi; fprintf("The estimated principle st...

17 days ago | 0

| accepted

Answered

Clustering electricity consumption time series into two customer groups.

I'm actually not sure if there are MATLAB functions that support these analyses, but I think the models you want are known as "L...

Clustering electricity consumption time series into two customer groups.

I'm actually not sure if there are MATLAB functions that support these analyses, but I think the models you want are known as "L...

17 days ago | 0

Answered

error analysis with errbar function

This section of the documentation explains how to control error bar length in all directions.

error analysis with errbar function

This section of the documentation explains how to control error bar length in all directions.

17 days ago | 0

Answered

Why doesn't this matlab code work?!

You missed a spot where you needed an element-wise operation, multiplying the exp(x) by the other term: x = -5:1:5; y = exp(x)...

Why doesn't this matlab code work?!

You missed a spot where you needed an element-wise operation, multiplying the exp(x) by the other term: x = -5:1:5; y = exp(x)...

18 days ago | 0

| accepted

Answered

Reducing memory of variables

Yes, there are many numeric types that use less memory than a double. Looks like you could use an 8-bit unsigned integer.

Reducing memory of variables

Yes, there are many numeric types that use less memory than a double. Looks like you could use an 8-bit unsigned integer.

18 days ago | 0

| accepted

Answered

vector with spacing (predefined)

Does v = -25:5:15 do what you want? Or maybe you meant initial_value = -25; step_size = 5; final_value = 15; v = initial...

vector with spacing (predefined)

Does v = -25:5:15 do what you want? Or maybe you meant initial_value = -25; step_size = 5; final_value = 15; v = initial...

19 days ago | 0

Answered

Can someone please help me stop "Index exceeds array bounds." in iteration? Any help is highly appreciated.

In your for loop, when n==5, your code tries to execute x1(n-1) which is x1(4) But your vector x1 is length 3, so there is n...

Can someone please help me stop "Index exceeds array bounds." in iteration? Any help is highly appreciated.

In your for loop, when n==5, your code tries to execute x1(n-1) which is x1(4) But your vector x1 is length 3, so there is n...

20 days ago | 0

Answered

How to remove space between bars in bar graph for unequally spaced data?

To me, it seems like a bad idea to make the bars evenly spaced, if the data are not from evenly spaced years. If the x-axis repr...

How to remove space between bars in bar graph for unequally spaced data?

To me, it seems like a bad idea to make the bars evenly spaced, if the data are not from evenly spaced years. If the x-axis repr...

20 days ago | 0

Answered

M-point averaging filter

You should be able to use the movmean function. For example: % Define some data A = reshape(1:15,3,5); % Take the moving av...

M-point averaging filter

You should be able to use the movmean function. For example: % Define some data A = reshape(1:15,3,5); % Take the moving av...

20 days ago | 0

| accepted

Answered

How to get a license?

The starting point for acquiring a campus-wide license is here. To find MATLAB options for yourself, click on the Get MATLAB bu...

How to get a license?

The starting point for acquiring a campus-wide license is here. To find MATLAB options for yourself, click on the Get MATLAB bu...

20 days ago | 1

Answered

convert to cell array

You can probably use the datevec function datevec('19:33:02.58')

convert to cell array

You can probably use the datevec function datevec('19:33:02.58')

22 days ago | 0