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

How to Split data into 3 equal parts (A,B,C) with balanced numbers of each subclass.

Probably the easiest way to do this would be with the following steps: Isolate each of the classes, using something like "Y == ...

How to Split data into 3 equal parts (A,B,C) with balanced numbers of each subclass.

Probably the easiest way to do this would be with the following steps: Isolate each of the classes, using something like "Y == ...

etwa 22 Stunden ago | 0

Answered

Plotting graphs with setting my own scales

figure hold on fplot (@ (x)x.^2 -2) fplot (@(x) sqrt(x+2)) fplot (@(x) (x.^2 + 2)./(2*x-1) ) fplot (@(x) (x.^2 + 2)./(2*...

Plotting graphs with setting my own scales

figure hold on fplot (@ (x)x.^2 -2) fplot (@(x) sqrt(x+2)) fplot (@(x) (x.^2 + 2)./(2*x-1) ) fplot (@(x) (x.^2 + 2)./(2*...

ein Tag ago | 0

| accepted

Answered

How I plot this ?

You can use the fimplicit function. alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; f = @(x,y) log((1+alpha1*x./(1+alph...

How I plot this ?

You can use the fimplicit function. alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; f = @(x,y) log((1+alpha1*x./(1+alph...

3 Tage ago | 0

Answered

How I plot this ?

Here is one way: alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; x = 0 : 0.1 : 10; y = 0 : 0.1 : 10; [xx,yy] = me...

How I plot this ?

Here is one way: alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; x = 0 : 0.1 : 10; y = 0 : 0.1 : 10; [xx,yy] = me...

3 Tage ago | 1

| accepted

Answered

Adding 2 string row to beginning row and end row of a matrix

A numeric data type cannot hold text. You'll need to store your data in a variable that can hold mixed types. One possibility is...

Adding 2 string row to beginning row and end row of a matrix

A numeric data type cannot hold text. You'll need to store your data in a variable that can hold mixed types. One possibility is...

3 Tage ago | 0

| accepted

Answered

For the following code, It shows my 51 iterations, however i only want to display the last iteration

Looks like you could just pull these lines out, and put them after the end statement of the loop: disp(['Error as percentage: '...

For the following code, It shows my 51 iterations, however i only want to display the last iteration

Looks like you could just pull these lines out, and put them after the end statement of the loop: disp(['Error as percentage: '...

3 Tage ago | 0

Answered

Concatenate vertically multiple tables with different dimensions

You can do this with the outerjoin command: A = table([1001; 1002; 1003],{'Jones';'James';'Robert'},... 'VariableNames...

Concatenate vertically multiple tables with different dimensions

You can do this with the outerjoin command: A = table([1001; 1002; 1003],{'Jones';'James';'Robert'},... 'VariableNames...

4 Tage ago | 0

| accepted

Answered

Standard deviation of values with standard deviation

The question you are asking is a specific instance of "propagation of uncertainty". You might want to learn more about the topic...

Standard deviation of values with standard deviation

The question you are asking is a specific instance of "propagation of uncertainty". You might want to learn more about the topic...

4 Tage ago | 2

| accepted

Answered

How to remove elements from two arrays when one of them has a zero

idx_to_remove = target_2019==0; target_2019(idx_to_remove) = []; output_2019(idx_to_remove) = [];

How to remove elements from two arrays when one of them has a zero

idx_to_remove = target_2019==0; target_2019(idx_to_remove) = []; output_2019(idx_to_remove) = [];

4 Tage ago | 1

Answered

Put specific name in file via writematrix

You need to concatenate the character arrays. Here is one way to do that: str='2020' writematrix(A,['output',str,'.xlsx'])

Put specific name in file via writematrix

You need to concatenate the character arrays. Here is one way to do that: str='2020' writematrix(A,['output',str,'.xlsx'])

8 Tage ago | 0

| accepted

Answered

Displaying a group of vectors on separate lines

You can use a semicolon to concatenate vertically [a; b; c]

Displaying a group of vectors on separate lines

You can use a semicolon to concatenate vertically [a; b; c]

9 Tage ago | 0

Answered

Issues converting a Cell to a numerical array

Here is one way that may work for you: C = {1, 3, 7, 7, 'a'}; N = cell2mat(C(cellfun(@isnumeric,C)))

Issues converting a Cell to a numerical array

Here is one way that may work for you: C = {1, 3, 7, 7, 'a'}; N = cell2mat(C(cellfun(@isnumeric,C)))

11 Tage ago | 0

Answered

3D Matrix Multiplication

You can do it straightforwardly with a for loop: % Some made-up input data A = rand(3,1,4); B = rand(3,3,4); [mA,nA,pA] = ...

3D Matrix Multiplication

You can do it straightforwardly with a for loop: % Some made-up input data A = rand(3,1,4); B = rand(3,3,4); [mA,nA,pA] = ...

11 Tage ago | 0

| accepted

Answered

fitlm() with 0 intercept function returns different values for R2 betwen MATLAB 2020a and 2020b?

Interesting. The 2020b result seems to be correct, based on the formula using sums of squares. (See, e.g. the definition on wiki...

fitlm() with 0 intercept function returns different values for R2 betwen MATLAB 2020a and 2020b?

Interesting. The 2020b result seems to be correct, based on the formula using sums of squares. (See, e.g. the definition on wiki...

11 Tage ago | 1

| accepted

Answered

Creating a Histogram of Letter grades converted from number grades

I'm sorry to say that the approach in your code is so misguided, that it is probably not worth debugging it. You need a differen...

Creating a Histogram of Letter grades converted from number grades

I'm sorry to say that the approach in your code is so misguided, that it is probably not worth debugging it. You need a differen...

12 Tage ago | 0

Answered

how to get random pair ?

How are these pairs currently stored? This seems equivalent to just choosing a random number from 1-6, so you could do idx = r...

how to get random pair ?

How are these pairs currently stored? This seems equivalent to just choosing a random number from 1-6, so you could do idx = r...

12 Tage ago | 0

Answered

How to plot function with variable input like shown in figure?

I didn't fully understand what you are trying to do, but the fplot command might be useful.

How to plot function with variable input like shown in figure?

I didn't fully understand what you are trying to do, but the fplot command might be useful.

13 Tage ago | 0

Answered

Producing a NaN only where there is a NaN, zero otherwise

Second attempt ... X = [-inf, -1, -eps, 0, realmin, 2, 1+i, pi, flintmax, realmax, inf, NaN]; broken = @(x) 0./(isnan(x)-1); %...

Producing a NaN only where there is a NaN, zero otherwise

Second attempt ... X = [-inf, -1, -eps, 0, realmin, 2, 1+i, pi, flintmax, realmax, inf, NaN]; broken = @(x) 0./(isnan(x)-1); %...

13 Tage ago | 1

Answered

Producing a NaN only where there is a NaN, zero otherwise

First attempt: X = [-inf, -1, -eps, 0, realmin, 2, 1+i, pi, flintmax, realmax, inf, NaN]; broken = @(x) 1./((isnan(x)-1)/0); %...

Producing a NaN only where there is a NaN, zero otherwise

First attempt: X = [-inf, -1, -eps, 0, realmin, 2, 1+i, pi, flintmax, realmax, inf, NaN]; broken = @(x) 1./((isnan(x)-1)/0); %...

13 Tage ago | 1

Answered

How do I remove NaN's from my data?

If your numeric vector is called "x", then x(isnan(x)) = []; will remove the NaN values.

How do I remove NaN's from my data?

If your numeric vector is called "x", then x(isnan(x)) = []; will remove the NaN values.

14 Tage ago | 0

Answered

Plot of 4D coordinates

You may be able to find something you can adapt at the MATLAB Plot Gallery.

Plot of 4D coordinates

You may be able to find something you can adapt at the MATLAB Plot Gallery.

14 Tage ago | 0

Answered

How to get the first value in a set of array that is bigger than the first few values?

Because x and y are not the same length, I'm not sure how to make the "correspondence" between them. However, this code snippet ...

How to get the first value in a set of array that is bigger than the first few values?

Because x and y are not the same length, I'm not sure how to make the "correspondence" between them. However, this code snippet ...

15 Tage ago | 1

Answered

Using if condition store values in an array

If I understand you correctly, this does what you want. (It doesn't directly use "if", but does the job via logical indexing ins...

Using if condition store values in an array

If I understand you correctly, this does what you want. (It doesn't directly use "if", but does the job via logical indexing ins...

16 Tage ago | 0

| accepted

Answered

Sort an Array with sortrows ( ) with two columns

See my answer (and other comments) to this very similar question. (As with the comments above, the premise is that the displayed...

Sort an Array with sortrows ( ) with two columns

See my answer (and other comments) to this very similar question. (As with the comments above, the premise is that the displayed...

16 Tage ago | 1

Answered

How to make slope 1in fitlm?

I don't believe you can do it with fitlm, but you can with fitnlm: % Set seed for reproducibility rng default % Make up som...

How to make slope 1in fitlm?

I don't believe you can do it with fitlm, but you can with fitnlm: % Set seed for reproducibility rng default % Make up som...

16 Tage ago | 0

| accepted

Answered

Multiplying a Matrix with every column of another matrix

Do you mean you just want to do standard matrix multipication? C = A * B Or did I misunderstand?

Multiplying a Matrix with every column of another matrix

Do you mean you just want to do standard matrix multipication? C = A * B Or did I misunderstand?

17 Tage ago | 1

| accepted

Answered

How to remove this error?

We can't really answer that for you, because we need more information. Suppose x = [1 2 3 4]; y = [5 6 2 3]; If I want to pl...

How to remove this error?

We can't really answer that for you, because we need more information. Suppose x = [1 2 3 4]; y = [5 6 2 3]; If I want to pl...

17 Tage ago | 0

Answered

What is prodofsize?

It is mentioned in the "Backward Compatibility" section of the documentation of cellfun, although there doesn't seem to be any i...

What is prodofsize?

It is mentioned in the "Backward Compatibility" section of the documentation of cellfun, although there doesn't seem to be any i...

18 Tage ago | 0

| accepted

Answered

Array indices must be positive integers or logical values error

You need X = (2*r2*((cosd(0)*cosd(theta2)))); instead of X = (2*r2((cosd(0)*cosd(theta2)))); (Note that I used r2* instead o...

Array indices must be positive integers or logical values error

You need X = (2*r2*((cosd(0)*cosd(theta2)))); instead of X = (2*r2((cosd(0)*cosd(theta2)))); (Note that I used r2* instead o...

18 Tage ago | 0

Answered

How to insert multiple element after specific numbers in a vector?

Here is one way % Original logical vector input L = logical([1 0 1 1 0]); % The numbers to be inserted oneNum = 6; zeroNu...

How to insert multiple element after specific numbers in a vector?

Here is one way % Original logical vector input L = logical([1 0 1 1 0]); % The numbers to be inserted oneNum = 6; zeroNu...

21 Tage ago | 0