Community Profile

# the cyclist

##### Last seen: Today
4,540 total contributions since 2011

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

View all

Contributions in
View by

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

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

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

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

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

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

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

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

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

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

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

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

How can I plot average and then the error bar with standard deviation?
You can use the errorbar function.

10 days ago | 0

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

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

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

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

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

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

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

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

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

17 days ago | 0

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

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

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

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

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

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