Answered

How do you load m-files that contain filenames with integers and strings?

Use the %d notation, and a cell array for storing: for ii = 1:50 B{ii} = load(sprintf('TTsim%dVariable.mat',ii)); end

How do you load m-files that contain filenames with integers and strings?

Use the %d notation, and a cell array for storing: for ii = 1:50 B{ii} = load(sprintf('TTsim%dVariable.mat',ii)); end

27 days ago | 0

Answered

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

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

27 days ago | 0

| accepted

Answered

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

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

28 days ago | 1

| accepted

Answered

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

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

29 days ago | 0

| accepted

Answered

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

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

29 days ago | 0

| accepted

Answered

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

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

29 days ago | 0

Answered

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

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

1 month ago | 0

| accepted

Answered

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)

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)

1 month ago | 2

| accepted

Answered

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

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

1 month ago | 0

| accepted

Answered

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

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

1 month ago | 0

Answered

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

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

1 month ago | 0

| accepted

Answered

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

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

1 month ago | 1

| accepted

Answered

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

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

1 month ago | 0

Answered

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

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

1 month ago | 0

| accepted

Answered

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

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 month ago | 1

| accepted

Answered

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

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

1 month ago | 0

Answered

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

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

1 month ago | 1

| accepted

Answered

Find indices of column/row in double that have matching value

Sounds like you could use either the find or ismember command.

Find indices of column/row in double that have matching value

Sounds like you could use either the find or ismember command.

1 month ago | 0

| accepted

Answered

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

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

1 month ago | 2

Answered

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

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

1 month ago | 0

| accepted

Answered

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

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

1 month ago | 0

| accepted

Answered

Problem with radians and degrees

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

Problem with radians and degrees

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

2 months ago | 0

| accepted

Answered

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

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

2 months ago | 2

| accepted

Answered

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

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

2 months ago | 0

| accepted

Answered

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

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

2 months ago | 0

| accepted

Answered

How can I plot average and then the error bar with standard deviation?

You can use the errorbar function.

How can I plot average and then the error bar with standard deviation?

You can use the errorbar function.

2 months ago | 0

Answered

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

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

2 months ago | 0

Answered

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

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

2 months ago | 1

| accepted

Answered

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

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

2 months ago | 0

| accepted

Answered

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

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

2 months ago | 0