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 get the indices of the values inside every bin i.e. histcounts2

Suppose you want to know which elements are in the bin that is 8 down and 6 across. Then binToFind = [8 6]; [tf,loc] = ismembe...

How to get the indices of the values inside every bin i.e. histcounts2

Suppose you want to know which elements are in the bin that is 8 down and 6 across. Then binToFind = [8 6]; [tf,loc] = ismembe...

1 day ago | 1

| accepted

Answered

How to write a for loop that creates a vector of [1:1000, 1001:2000,....,n]

% Define block size and number of blocks blockSize = 1000; numberBlocks = 50; % Create vector of all values A = 1:(blockSi...

How to write a for loop that creates a vector of [1:1000, 1001:2000,....,n]

% Define block size and number of blocks blockSize = 1000; numberBlocks = 50; % Create vector of all values A = 1:(blockSi...

3 days ago | 0

| accepted

Answered

fitcecoc SVM with categorical predictors not predicting the correct label for multiclass problem.

I'm pretty sure you've got your dummy encoding wrong. You are treating 1,2 and 3 as if they are somehow the same categories in ...

fitcecoc SVM with categorical predictors not predicting the correct label for multiclass problem.

I'm pretty sure you've got your dummy encoding wrong. You are treating 1,2 and 3 as if they are somehow the same categories in ...

4 days ago | 0

Answered

How can i include error calculation in the linear regression in a for loop?

The regress function outputs confidence intervals for the slope and intercept.

How can i include error calculation in the linear regression in a for loop?

The regress function outputs confidence intervals for the slope and intercept.

4 days ago | 0

Answered

Incorrect numerical integration, how to fix?

MATLAB's result is correct. You must have made a mistake on your calculator. You can verify this calculation that I entered int...

Incorrect numerical integration, how to fix?

MATLAB's result is correct. You must have made a mistake on your calculator. You can verify this calculation that I entered int...

4 days ago | 0

Answered

How can I extract data and match it from two different data??

If your first vector is only ones and zeros, then it is as simple as idx = [ 0 0 0 0 1 1 1 0 0 0 ]; b = [ 5 5 5 5 10 10 10 6 6...

How can I extract data and match it from two different data??

If your first vector is only ones and zeros, then it is as simple as idx = [ 0 0 0 0 1 1 1 0 0 0 ]; b = [ 5 5 5 5 10 10 10 6 6...

4 days ago | 0

| accepted

Answered

help with max function

This code will return the row and column indices where the entry is equal to the column's maximum. [rowIdx,colIdx] = find(A==ma...

help with max function

This code will return the row and column indices where the entry is equal to the column's maximum. [rowIdx,colIdx] = find(A==ma...

6 days ago | 0

| accepted

Answered

Bar Plots with errorbars with limits

Do you mean something like this? % Pretend data x = linspace(0,10,25); y = linspace(0,1,25); se = y/10; % Amount that e...

Bar Plots with errorbars with limits

Do you mean something like this? % Pretend data x = linspace(0,10,25); y = linspace(0,1,25); se = y/10; % Amount that e...

6 days ago | 0

| accepted

Answered

Removing values from two different variables

% For each cell of AL, find the non-2's keepIndices = cellfun(@(x)x~=2,AL,'UniformOutput',false); % Keep the elements of AL ...

Removing values from two different variables

% For each cell of AL, find the non-2's keepIndices = cellfun(@(x)x~=2,AL,'UniformOutput',false); % Keep the elements of AL ...

6 days ago | 0

| accepted

Answered

accuracy of coefficients using fit with power1

I don't have the Curve Fitting Toolbox, so I can't investigate directly. If you have the Statistics and Machine Learning Toolbox...

accuracy of coefficients using fit with power1

I don't have the Curve Fitting Toolbox, so I can't investigate directly. If you have the Statistics and Machine Learning Toolbox...

9 days ago | 1

Answered

types of functions in matlab

A google search quickly came up with this documentation page and this documentation page that will probably answer your question...

types of functions in matlab

A google search quickly came up with this documentation page and this documentation page that will probably answer your question...

10 days ago | 2

| accepted

Answered

Number of variables vary in function definition

Here is a different approach, using a loop and sprintf: % Count columns and preallocate X numberCols = size(A,2); X1 = cell(1...

Number of variables vary in function definition

Here is a different approach, using a loop and sprintf: % Count columns and preallocate X numberCols = size(A,2); X1 = cell(1...

11 days ago | 1

| accepted

Answered

Matrix with ones and zeros

Do you mean that you want every possible combination of 3x3 matrix filled with 0 or 1? The following is pretty obfuscated code, ...

Matrix with ones and zeros

Do you mean that you want every possible combination of 3x3 matrix filled with 0 or 1? The following is pretty obfuscated code, ...

11 days ago | 0

| accepted

Answered

Attempt to grow array along ambiguous dimension.

The way your defined your mult variables, they are 81-dimensional arrays. I think you meant: multA = ones(size(a)); multB = on...

Attempt to grow array along ambiguous dimension.

The way your defined your mult variables, they are 81-dimensional arrays. I think you meant: multA = ones(size(a)); multB = on...

12 days ago | 0

Answered

Loops slowing down dramatically with increased iterations

I have not gone through your code, but this is a classic symptom of failing to preallocate matrices, and instead letting them gr...

Loops slowing down dramatically with increased iterations

I have not gone through your code, but this is a classic symptom of failing to preallocate matrices, and instead letting them gr...

12 days ago | 0

Answered

Matrix transformation (sorting)

i = find(sort(A,'descend')); j = find(A); s = numel(A); T = zeros(s,s); T(sub2ind([s s],i,j)) = 1; I hope it's clear what...

Matrix transformation (sorting)

i = find(sort(A,'descend')); j = find(A); s = numel(A); T = zeros(s,s); T(sub2ind([s s],i,j)) = 1; I hope it's clear what...

12 days ago | 0

| accepted

Answered

How do I name the columns of my table by the names of row 1?

Did you try reading the documentation page for readtable? It seems that all you need to do is this: pos=readtable("Pos_data.cs...

How do I name the columns of my table by the names of row 1?

Did you try reading the documentation page for readtable? It seems that all you need to do is this: pos=readtable("Pos_data.cs...

13 days ago | 1

Answered

Remove zeros from a 3D array

Do you mean you have "slices" of all zeros? Then this should work: % Create an array like your A matrix, where some "slices" of...

Remove zeros from a 3D array

Do you mean you have "slices" of all zeros? Then this should work: % Create an array like your A matrix, where some "slices" of...

13 days ago | 0

| accepted

Answered

Matrix transformation (sorting)

T = sort(A,'descend')/A Note that I am only using sort here to define the result you need. The transformation matrix you get as...

Matrix transformation (sorting)

T = sort(A,'descend')/A Note that I am only using sort here to define the result you need. The transformation matrix you get as...

13 days ago | 1

Answered

Scatterplot, i need to plot one point instead of 4 present in my table

If I understand correctly, you want to do the following: A_mean = mean(reshape(A,4,[]))'; B_mean = mean(reshape(B,4,[]))'; C_...

Scatterplot, i need to plot one point instead of 4 present in my table

If I understand correctly, you want to do the following: A_mean = mean(reshape(A,4,[]))'; B_mean = mean(reshape(B,4,[]))'; C_...

17 days ago | 0

Answered

Fastest way to match elements in two vectors and return indices?

I have to admit that I have not dug into your code, but it sounds like the ismember function might be useful.

Fastest way to match elements in two vectors and return indices?

I have to admit that I have not dug into your code, but it sounds like the ismember function might be useful.

18 days ago | 0

Answered

summing elements of an array until a value appears

Here is one way. % Inputs inputVector = [5 4 3 2 1]; inputValueToFind = 2; % Find the location of the index idxEnd = find...

summing elements of an array until a value appears

Here is one way. % Inputs inputVector = [5 4 3 2 1]; inputValueToFind = 2; % Find the location of the index idxEnd = find...

18 days ago | 0

Answered

How to translate Wolfram program to Matlab

Almost always, the best and "safest" thing to do is to understand what the underlying code is doing in the old language, and the...

How to translate Wolfram program to Matlab

Almost always, the best and "safest" thing to do is to understand what the underlying code is doing in the old language, and the...

18 days ago | 0

Answered

create diagonal matrix zeros

a = diag(1:10); a(1,:) = 1:10; a(:,1) = 1:10;

create diagonal matrix zeros

a = diag(1:10); a(1,:) = 1:10; a(:,1) = 1:10;

20 days ago | 0

| accepted

Answered

How would I find the value of a corresponding data set?

When you say "corresponding", do you mean the 5th y(value) or the 3rd? y(index)

How would I find the value of a corresponding data set?

When you say "corresponding", do you mean the 5th y(value) or the 3rd? y(index)

20 days ago | 0

Answered

How to randomly select values in one matrix and make them equal to values of a second matrix?

while ... % <---- condition goes here idx = randi(400); x(idx) = y(idx); end

How to randomly select values in one matrix and make them equal to values of a second matrix?

while ... % <---- condition goes here idx = randi(400); x(idx) = y(idx); end

20 days ago | 0

Answered

how can I find the probabilities of the ecdf function of each duplicate values in y ?

Do you mean you are trying to get these values? histcounts(num_off_time,'Normalization','probability') ans = 0.2000 ...

how can I find the probabilities of the ecdf function of each duplicate values in y ?

Do you mean you are trying to get these values? histcounts(num_off_time,'Normalization','probability') ans = 0.2000 ...

20 days ago | 0

| accepted

Answered

Random order with constraints

If you have the Statistics and Machine Learning Toolbox, you could do it like this: x = sort(randsample(220,20,false)); while ...

Random order with constraints

If you have the Statistics and Machine Learning Toolbox, you could do it like this: x = sort(randsample(220,20,false)); while ...

20 days ago | 1

Answered

Problem with obtain regression equation between 2 data sets

All these methods will give the same coefficient for the y/x sloped if you scale the variables first: rng default N = 10; ...

Problem with obtain regression equation between 2 data sets

All these methods will give the same coefficient for the y/x sloped if you scale the variables first: rng default N = 10; ...

21 days ago | 1