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

Delete overlaping intervals in matrix

I expect there is a more elegant approach, but here is a straightforward way: M = [100 200 5; 150 210 7; 205 300 9;...

Delete overlaping intervals in matrix

I expect there is a more elegant approach, but here is a straightforward way: M = [100 200 5; 150 210 7; 205 300 9;...

1 day ago | 0

Answered

Delete overlaping intervals in matrix

I believe this does what you want: M = [100 200; 150 210; 190 300; 300 400; 410 600; 500 700]; keepRow = M(2:end,1) >= M(1:end...

Delete overlaping intervals in matrix

I believe this does what you want: M = [100 200; 150 210; 190 300; 300 400; 410 600; 500 700]; keepRow = M(2:end,1) >= M(1:end...

1 day ago | 1

Answered

I want to use the Python libraries in MATLAB

Have you seen this documentation on calling python modules from MATLAB?

I want to use the Python libraries in MATLAB

Have you seen this documentation on calling python modules from MATLAB?

1 day ago | 0

Answered

how can I put the histfit function in terms of probability?

Here's one way: % Made-up data data = randn(500,1); % Fit to a normal (or a different distribution if you choose) pd = fit...

how can I put the histfit function in terms of probability?

Here's one way: % Made-up data data = randn(500,1); % Fit to a normal (or a different distribution if you choose) pd = fit...

3 days ago | 0

Answered

help with error "Reference to a cleared variable n"

Putting clear all inside the function clears the variable n that you just sent into it. You don't need that line.

help with error "Reference to a cleared variable n"

Putting clear all inside the function clears the variable n that you just sent into it. You don't need that line.

3 days ago | 0

| accepted

Answered

Using regexp to extract day number from long string

Is the directory depth reliably constant? If so, then % Input data str = 'folder\files and things\1996\other folder\ 6 <month>...

Using regexp to extract day number from long string

Is the directory depth reliably constant? If so, then % Input data str = 'folder\files and things\1996\other folder\ 6 <month>...

4 days ago | 0

Answered

Limiting the values of a column

If you mean that y is a column vector, then y_new = y((y>=-10) & (y<=10)) will give you a new column vector with only the valu...

Limiting the values of a column

If you mean that y is a column vector, then y_new = y((y>=-10) & (y<=10)) will give you a new column vector with only the valu...

4 days ago | 0

| accepted

Answered

Need help fitting given data to an exponential function

If you have the Statistics and Machine Learning Toolbox, you might be able to use the expfit function. If not, and you don't ha...

Need help fitting given data to an exponential function

If you have the Statistics and Machine Learning Toolbox, you might be able to use the expfit function. If not, and you don't ha...

6 days ago | 0

Answered

How to search for an exact string not just contains

Use strcmp instead, which checks for identical matches. loc = {'Las Vegas, NV','North Las Vegas, NV'}; match = strcmp(loc,'L...

How to search for an exact string not just contains

Use strcmp instead, which checks for identical matches. loc = {'Las Vegas, NV','North Las Vegas, NV'}; match = strcmp(loc,'L...

6 days ago | 0

Answered

Counting every other number in a list

I'm not sure what you mean by "count" them, but the following vector will store every other element from mylist, starting with t...

Counting every other number in a list

I'm not sure what you mean by "count" them, but the following vector will store every other element from mylist, starting with t...

7 days ago | 0

| accepted

Answered

gaussian plot on my histogram

If you have the Statistics and Machine Learning Toolbox, you can use the histfit function to do the histogram and gaussian fit a...

gaussian plot on my histogram

If you have the Statistics and Machine Learning Toolbox, you can use the histfit function to do the histogram and gaussian fit a...

10 days ago | 0

Answered

Who is using the MATLAB Discord channel?

This is the first I've heard of MATLAB having a Discord channel

Who is using the MATLAB Discord channel?

This is the first I've heard of MATLAB having a Discord channel

10 days ago | 1

Answered

Get size of each element in a cell

You can use the cellfun command: cellfun(@size,myCell,'UniformOutput',false)

Get size of each element in a cell

You can use the cellfun command: cellfun(@size,myCell,'UniformOutput',false)

11 days ago | 1

| accepted

Answered

How to interpret PCA

@Jin Woo: If search this forum for cyclist and pca, you will find a few question/answers where I explain a lot about the interp...

How to interpret PCA

@Jin Woo: If search this forum for cyclist and pca, you will find a few question/answers where I explain a lot about the interp...

11 days ago | 0

Answered

Numbering results from for loop with the iteration they come from

Don't use separate variable names. Use the cell array data type: K{i} = ( ( EALtheta(i,1) * EALtheta(i,2) ) / EALtheta(i,3) )*...

Numbering results from for loop with the iteration they come from

Don't use separate variable names. Use the cell array data type: K{i} = ( ( EALtheta(i,1) * EALtheta(i,2) ) / EALtheta(i,3) )*...

13 days ago | 0

Answered

Array indices must be positive integers or logical values.

It seems that you have tried to use this line of code: funcnew01=z^5+z^3-pi; to define a general function on z. Then you try t...

Array indices must be positive integers or logical values.

It seems that you have tried to use this line of code: funcnew01=z^5+z^3-pi; to define a general function on z. Then you try t...

13 days ago | 1

| accepted

Answered

Compute the summation of all elements square of matrix

This looks like homework. In the future, please listen to James Tursa's advice, and post what you have tried, be specific about...

Compute the summation of all elements square of matrix

This looks like homework. In the future, please listen to James Tursa's advice, and post what you have tried, be specific about...

14 days ago | 0

Answered

Why is the (second) if statement in the for loop not working?

I don't know if this is perfectly correct, but it is certainly closer: Where you have i_Last(i) = Faktor*(i_0+(i_Amp*(1-exp(-(...

Why is the (second) if statement in the for loop not working?

I don't know if this is perfectly correct, but it is certainly closer: Where you have i_Last(i) = Faktor*(i_0+(i_Amp*(1-exp(-(...

18 days ago | 0

| accepted

Answered

How can I extract numbers from a column in a matrix dependent on a number in another column ?

If your matrix is A, then output = log(A(A(:,4)==2,9)); In case it is not obvious what that one line of code is going, work fr...

How can I extract numbers from a column in a matrix dependent on a number in another column ?

If your matrix is A, then output = log(A(A(:,4)==2,9)); In case it is not obvious what that one line of code is going, work fr...

18 days ago | 1

| accepted

Answered

Different machine precision for scalars and vectors?

If you don't have a specific reason to be using a for loop here, why not also teach them canonical use of vectorized calculation...

Different machine precision for scalars and vectors?

If you don't have a specific reason to be using a for loop here, why not also teach them canonical use of vectorized calculation...

19 days ago | 1

Answered

Shade the encircled area

Combining your new code that aligns the values of t (but not using your attempt at creating the patch), and the same basic idea ...

Shade the encircled area

Combining your new code that aligns the values of t (but not using your attempt at creating the patch), and the same basic idea ...

19 days ago | 1

Answered

How can I create a scatterplot matrix?

Here is one way: T = readtable('Stress_Reactivity.xlsx'); figure gscatter(T.cort_3,T.diastolic_3,T.condition) I recommend ...

How can I create a scatterplot matrix?

Here is one way: T = readtable('Stress_Reactivity.xlsx'); figure gscatter(T.cort_3,T.diastolic_3,T.condition) I recommend ...

20 days ago | 0

Answered

Saving a m file

Are you using the MATLAB editor? On the editor tab, there is an icon for saving the file you are editing.

Saving a m file

Are you using the MATLAB editor? On the editor tab, there is an icon for saving the file you are editing.

20 days ago | 0

Answered

Julian day to date

Here is one way: dateTable = readtable('KALAMARIA_2007.xlsx','Range','C:D'); julianDate = datetime(dateTable.YEAR,1,dateTabl...

Julian day to date

Here is one way: dateTable = readtable('KALAMARIA_2007.xlsx','Range','C:D'); julianDate = datetime(dateTable.YEAR,1,dateTabl...

20 days ago | 0

Answered

How to I find X unique combinations (order doesn't matter) of X numbers within an array of X numbers.

There's probably a more efficient way, since I effectively first find all combinations, but I think this does what you want, in ...

How to I find X unique combinations (order doesn't matter) of X numbers within an array of X numbers.

There's probably a more efficient way, since I effectively first find all combinations, but I think this does what you want, in ...

21 days ago | 1

Answered

unique vector with restrictions

I suggest you read this post about why dynamically named variables are a bad idea. Instead, you'd be better off storing your vec...

unique vector with restrictions

I suggest you read this post about why dynamically named variables are a bad idea. Instead, you'd be better off storing your vec...

21 days ago | 0

| accepted

Answered

Why do I get this error message "Array indices must be positive integers or logical values."

You have three distinct problems in this one line of code: Z = x.^2*y(y-1)*(y+1) One of them is causing the error you are seei...

Why do I get this error message "Array indices must be positive integers or logical values."

You have three distinct problems in this one line of code: Z = x.^2*y(y-1)*(y+1) One of them is causing the error you are seei...

22 days ago | 0

| accepted

Answered

I wish to move the tabs from the side, to up, please help

In your screenshot, see where there is a "View" tab along the top? Click that, and then use the "Tabs Position". This answer sh...

I wish to move the tabs from the side, to up, please help

In your screenshot, see where there is a "View" tab along the top? Click that, and then use the "Tabs Position". This answer sh...

22 days ago | 0

Answered

Loop generation doubt.

% DO NOT USE THESE. USE YOUR DATA. THESE ARE FOR AN EXAMPLE ONLY T = rand(160547,1); A = rand(44880,1); k = rand(size(A)); w...

Loop generation doubt.

% DO NOT USE THESE. USE YOUR DATA. THESE ARE FOR AN EXAMPLE ONLY T = rand(160547,1); A = rand(44880,1); k = rand(size(A)); w...

27 days ago | 0

| accepted

Answered

Loop generation doubt.

You don't need to use a loop. MATLAB will do vectorized calculations. If you have a fairly recent version of MATLAB, you can do...

Loop generation doubt.

You don't need to use a loop. MATLAB will do vectorized calculations. If you have a fairly recent version of MATLAB, you can do...

27 days ago | 0