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

Change color of graph at a certain value (temperature vs. time)

One option would be to draw the data as points, perhaps with a thin black line to guide the eye to time-consecutive points. rng...

Change color of graph at a certain value (temperature vs. time)

One option would be to draw the data as points, perhaps with a thin black line to guide the eye to time-consecutive points. rng...

4 dagen ago | 0

Answered

What is the best practice of conditional statements in solving a complicatedly branched system?

An alternative would be to build up your expression via logical components of this form a = 2.0676; b = -0.2309; c = 4.342 ...

What is the best practice of conditional statements in solving a complicatedly branched system?

An alternative would be to build up your expression via logical components of this form a = 2.0676; b = -0.2309; c = 4.342 ...

4 dagen ago | 1

Answered

How to use diag() once and change values after certain element?

A simple way to construct the exact matrix in your first part is matrix = 2*eye(4) + diag([-1 -1 -1],-1) + diag([1 1 1],1) How...

How to use diag() once and change values after certain element?

A simple way to construct the exact matrix in your first part is matrix = 2*eye(4) + diag([-1 -1 -1],-1) + diag([1 1 1],1) How...

4 dagen ago | 0

| accepted

Answered

Behaviour of backslash operator for non-square matrices least-squares fitting

They are equal, to within floating-point precision. Notice that max(abs(c1(:)-c2(:))) is around 1e-16.

Behaviour of backslash operator for non-square matrices least-squares fitting

They are equal, to within floating-point precision. Notice that max(abs(c1(:)-c2(:))) is around 1e-16.

4 dagen ago | 1

| accepted

Answered

How to save each term from a sum

clear n = input('Number of terms: '); terms = zeros(n,1); for ni = 1:n terms(ni)=terms(ni) + (sum(1/(ni^2)...

How to save each term from a sum

clear n = input('Number of terms: '); terms = zeros(n,1); for ni = 1:n terms(ni)=terms(ni) + (sum(1/(ni^2)...

4 dagen ago | 0

Answered

keep getting errors on matlab

Instead of writing sin(t)cos(t) you need to put the explicit operations in, like this sin(t)*cos(t)

keep getting errors on matlab

Instead of writing sin(t)cos(t) you need to put the explicit operations in, like this sin(t)*cos(t)

5 dagen ago | 0

Answered

Showing : At least one END is missing: the statement may begin here.

The last line of rng.m is endfunction but it should be just end I also spotted another problem, which is that you should hav...

Showing : At least one END is missing: the statement may begin here.

The last line of rng.m is endfunction but it should be just end I also spotted another problem, which is that you should hav...

6 dagen ago | 0

Answered

Reshaping a 2 d matrix into a 3 d matrix row wise.

For your small example, if A is your original matrix, then permute(reshape(A',3,2,[]),[2 1 3]) For the larger one, permute(re...

Reshaping a 2 d matrix into a 3 d matrix row wise.

For your small example, if A is your original matrix, then permute(reshape(A',3,2,[]),[2 1 3]) For the larger one, permute(re...

7 dagen ago | 0

| accepted

Answered

Fit multiple data with one mathmatical model/function

I would restructure my data (see attached), and use the nlinfit function from the Machine Learning and Statistics Toolbox. This...

Fit multiple data with one mathmatical model/function

I would restructure my data (see attached), and use the nlinfit function from the Machine Learning and Statistics Toolbox. This...

7 dagen ago | 0

| accepted

Answered

Fill area between contour levels

I am hoping for your sake that there is a better way than this (possibly using the Image Processing Toolbox?), but here is one w...

Fill area between contour levels

I am hoping for your sake that there is a better way than this (possibly using the Image Processing Toolbox?), but here is one w...

7 dagen ago | 1

Answered

Turn a X Y Z matrix into a point cloud

xyzPoints = [1 8 9; 2 3 4; 9 8 6]; ptCloud = pointCloud(xyzPoints);

Turn a X Y Z matrix into a point cloud

xyzPoints = [1 8 9; 2 3 4; 9 8 6]; ptCloud = pointCloud(xyzPoints);

7 dagen ago | 0

Answered

Searching for minimum x root for known y

This code finds the minimum root, for y == 43. y = 43; p = [-0.1042 1.9167 13.062 39.333 45.083 21-y]; min(roots(...

Searching for minimum x root for known y

This code finds the minimum root, for y == 43. y = 43; p = [-0.1042 1.9167 13.062 39.333 45.083 21-y]; min(roots(...

8 dagen ago | 1

| accepted

Answered

get the x-value of a point on curve

When you say "get", do you mean from the vectors, or only from the curve? If you mean from the data, you can do, for example x...

get the x-value of a point on curve

When you say "get", do you mean from the vectors, or only from the curve? If you mean from the data, you can do, for example x...

8 dagen ago | 0

| accepted

Answered

How to Read and plot CSV file and delete infinity values from CSV file

I find that sometimes with these finicky imports it can be helpful to use the Import Data Tool. I used that as a basis to make ...

How to Read and plot CSV file and delete infinity values from CSV file

I find that sometimes with these finicky imports it can be helpful to use the Import Data Tool. I used that as a basis to make ...

8 dagen ago | 0

Answered

Converting matirx into vektor inside a cell array

ev1 = cellfun(@(x)x(:,1),V,'UniformOutput',false); ev2 = cellfun(@(x)x(:,2),V,'UniformOutput',false);

Converting matirx into vektor inside a cell array

ev1 = cellfun(@(x)x(:,1),V,'UniformOutput',false); ev2 = cellfun(@(x)x(:,2),V,'UniformOutput',false);

8 dagen ago | 1

Answered

Filling areas between curves

If you put this line after your line plotting, you'll see the basics of using the patch command: patch([x1; x1(1)],[y1; y1(1)],...

Filling areas between curves

If you put this line after your line plotting, you'll see the basics of using the patch command: patch([x1; x1(1)],[y1; y1(1)],...

9 dagen ago | 0

| accepted

Answered

How do you remove a trend from data without using the 'detrend' function?

Usually, when someone "doesn't want" to use a function, it means that it is homework, and they are not allowed to use a function...

How do you remove a trend from data without using the 'detrend' function?

Usually, when someone "doesn't want" to use a function, it means that it is homework, and they are not allowed to use a function...

9 dagen ago | 0

Answered

recursive function with 2 variables doesnt work

For me, your function works as expected. Maybe you accidentally also created a variable s in your workspace, and you are trying...

recursive function with 2 variables doesnt work

For me, your function works as expected. Maybe you accidentally also created a variable s in your workspace, and you are trying...

9 dagen ago | 0

| accepted

Answered

estimate main effects and interactions

I was able to replicate the effect estimates, but only via a rather odd normalization scheme of the variables: data = [1 10 220...

estimate main effects and interactions

I was able to replicate the effect estimates, but only via a rather odd normalization scheme of the variables: data = [1 10 220...

10 dagen ago | 0

| accepted

Answered

Receiving 'not enough input arguments' in code

You need rows>Rank instead of rows>rank MATLAB is case-sensitive. It would be better to have named that variable something t...

Receiving 'not enough input arguments' in code

You need rows>Rank instead of rows>rank MATLAB is case-sensitive. It would be better to have named that variable something t...

11 dagen ago | 0

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...

13 dagen 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...

15 dagen 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 ...

15 dagen 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.

15 dagen 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...

16 dagen 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...

16 dagen 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...

18 dagen 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...

18 dagen 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 ...

18 dagen 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...

21 dagen ago | 1