Community Profile

the cyclist

Last seen: Today
4,552 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

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
In this line: k0(i)=0.378893+1.4897153*w-0.17131848*w.^2+0.0196554*w.^3; w is a 2-element vector, and you are trying to assign...

5 hours ago | 0

Extracting data from two tables with the same ID's
I didn't completely follow what you are trying to do, but I'm pretty sure you should be able to use the join command to do what ...

8 hours ago | 0

Scatter Plot: X and Y must be vectors of the same length
SDT=[8702.28,7733.86,9790.18,5877.4,6690.84,6281.96,7846.98,5875.71,8098.65,6026.58,5885.59,4080.97,4940.49,4204.46,4451.12,5826...

1 day ago | 0

| accepted

Changing array elements relative to it's size and position in the array
I think this does what you want: % Original data R = [0, 0, 4, 0, 1, 0, 0, 0, 0, 6]; % Identify the non-zero elements of R ...

1 day ago | 0

Exponential Plot not acting correct
The plot behavior looks correct to me, according to the equation. If delta_V == 0, then lambda == 1. (You don't calculate/plot ...

1 day ago | 0

Several tangent vectors on curve
Well, you never actually calculated the tangent, so it is not that surprising you didn't get the correct result. t = linspace(-...

3 days ago | 0

| accepted

How can I insert numbers 1-100 into the first column of a cell array?
Here is one way: N = 100; % Set up an empty cell array C = cell(N,8); % Fill the first column C(:,1) = num2cell(1:N)

4 days ago | 2

| accepted

What exactly am i suppose to do to run this code
You can run that code by putting it into a file (that would canonically be called sh.m), and then calling that function from the...

4 days ago | 0

| accepted

How to select a range within a variable?
Take a look at this small example. First, define a smaller x vector: x = 1000:-1000:-6000 The variable x_is_small = (x < -40...

4 days ago | 0

Can anyone help me to apply RBF kernel function in matlab and how to write its equation?
% Define sigma sigma = 0.4; % Define the function K = @(x1,x2) exp(-sum((x1-x2).^2)./(2.*sigma.^2)); % Apply the functio...

7 days ago | 0

| accepted

Set unique elements to 0s and 1s matlab
Here is one way. I doubt it is the best. % Original table with two variables x = {'a','b','a','a','b'}.'; y = {'c','c','c','d...

8 days ago | 1

| accepted

Delete zeros form multiple columns in a matrix
A numeric data type cannot have empty elements. You have a couple options. You could use a cell array, which can have empty el...

9 days ago | 0

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

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

12 days ago | 1

| accepted

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

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

12 days ago | 1

| accepted

Find indices of column/row in double that have matching value
Sounds like you could use either the find or ismember command.

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

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

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

14 days ago | 0

| accepted

You need parentheses around 2*n. Otherwise, MATLAB will divide by 2, then multiply by n. % Chebshevy Poles clc clear ...

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

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

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

20 days ago | 0

| accepted

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

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

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

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

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

24 days ago | 0