Answered

How do I record the entire row of a matrix if it has a peak value in the third column?

Try this: [~,locs] = findpeaks(xyK(:,3)); sol = xyK(locs,:);

How do I record the entire row of a matrix if it has a peak value in the third column?

Try this: [~,locs] = findpeaks(xyK(:,3)); sol = xyK(locs,:);

15 hours ago | 0

| accepted

Answered

repeating a sequence of code

Do you mean this? n = 1; while n ~= 3 disp(' Choose an Option Below '); disp(' 1 Convert Decimal Number to Binary ...

repeating a sequence of code

Do you mean this? n = 1; while n ~= 3 disp(' Choose an Option Below '); disp(' 1 Convert Decimal Number to Binary ...

16 hours ago | 0

| accepted

Answered

creating array with entries as numbers

Do you mean this? n = 1.44:0.001:1.45;

creating array with entries as numbers

Do you mean this? n = 1.44:0.001:1.45;

2 days ago | 0

Answered

More efficient "for i in array" loops

Using your equations directly: x = [1 2 3 4 5 6]; c = 1; cos_theta = (1-((2*x)/c)); theta = acos(cos_theta);

More efficient "for i in array" loops

Using your equations directly: x = [1 2 3 4 5 6]; c = 1; cos_theta = (1-((2*x)/c)); theta = acos(cos_theta);

5 days ago | 0

Answered

My code won't run. It says there is an error in line 30.

There is an error in your calls to matlabFunction: function [] = Newton(f, x1, tol, N) % % Newton uses Newton’s method to app...

My code won't run. It says there is an error in line 30.

There is an error in your calls to matlabFunction: function [] = Newton(f, x1, tol, N) % % Newton uses Newton’s method to app...

6 days ago | 0

Answered

How to remove multiple elements in a row matrix

This is a very basic problem. I recommend you to do the Matlab tutorial Being A your array: A = A(2835:end);

How to remove multiple elements in a row matrix

This is a very basic problem. I recommend you to do the Matlab tutorial Being A your array: A = A(2835:end);

6 days ago | 0

Answered

Converting matirx into vektor inside a cell array

Try with this: for i=1:n for j=1:m ev1{j,i} = V{j,i}(:,1); ev2{j,i} = V{j,i}(:,2); end end

Converting matirx into vektor inside a cell array

Try with this: for i=1:n for j=1:m ev1{j,i} = V{j,i}(:,1); ev2{j,i} = V{j,i}(:,2); end end

6 days ago | 0

| accepted

Answered

campare a row value with the next row

Another option: a = [1;1;0;0;0;1;0;1;0;1]; b = diff(a); b(~b) = 2*a(~b); sol = splitapply(@numel,b,b+2) %Ordered as [1,0],...

campare a row value with the next row

Another option: a = [1;1;0;0;0;1;0;1;0;1]; b = diff(a); b(~b) = 2*a(~b); sol = splitapply(@numel,b,b+2) %Ordered as [1,0],...

6 days ago | 1

Answered

Solve a quadratic equation

To use the function roots you need to reformulate your equation: tau = 0.1 f4 = [3; 2; 6; 8] f8 = [2; 6; 7; 3] eq = @(f4,f...

Solve a quadratic equation

To use the function roots you need to reformulate your equation: tau = 0.1 f4 = [3; 2; 6; 8] f8 = [2; 6; 7; 3] eq = @(f4,f...

6 days ago | 0

| accepted

Answered

Error: Attempt to execute SCRIPT mesh as a function

Because your live script has the same name than the function mesh and when you call this function, in fact you are calling your ...

Error: Attempt to execute SCRIPT mesh as a function

Because your live script has the same name than the function mesh and when you call this function, in fact you are calling your ...

7 days ago | 0

| accepted

Answered

Index exceeds the number of array elements (1).

VarHigh is a constant and you are using it as an array... VarHigh(2) %Throws an error

Index exceeds the number of array elements (1).

VarHigh is a constant and you are using it as an array... VarHigh(2) %Throws an error

7 days ago | 0

Answered

How would I write this code without using loops?

Another option: N = 1000; five = 2*5:5:N; seven = 2*7:7:N; res = setxor(five,seven)

How would I write this code without using loops?

Another option: N = 1000; five = 2*5:5:N; seven = 2*7:7:N; res = setxor(five,seven)

21 days ago | 0

Answered

Hold on Not showing all of my plots on one graph

Take a look at the variables you are plotting, they are duplicated. I mean Bsigmay is equal to sigmay, Bsigmaz is equal to sigma...

Hold on Not showing all of my plots on one graph

Take a look at the variables you are plotting, they are duplicated. I mean Bsigmay is equal to sigmay, Bsigmaz is equal to sigma...

22 days ago | 0

| accepted

Answered

How do I use a vector as a set of indices?

Try this: m = 5000; num_labels = 10; y = randi(num_labels,m,1); yrec = zeros(num_labels,m); yrec(sub2ind(size(yrec),y',1:...

How do I use a vector as a set of indices?

Try this: m = 5000; num_labels = 10; y = randi(num_labels,m,1); yrec = zeros(num_labels,m); yrec(sub2ind(size(yrec),y',1:...

23 days ago | 0

| accepted

Answered

Problems using solve function for linear system of equations

Use assume function before solve: assume(0 < p1 < 270) assume(0 < p2 < 270) assume(0 < p3 < 270)

Problems using solve function for linear system of equations

Use assume function before solve: assume(0 < p1 < 270) assume(0 < p2 < 270) assume(0 < p3 < 270)

27 days ago | 0

Answered

Command to delete last row and column of a matrix

A(:,end) = []; %Delete last column A(end,:) = []; %Delete last row

Command to delete last row and column of a matrix

A(:,end) = []; %Delete last column A(end,:) = []; %Delete last row

29 days ago | 0

| accepted

Answered

How would I locate non-zeros given a condition?

For example: A = [1 0 1 1 0 0 0 1 0 0 0 0]; rows = find(A(:,4) & sum(A(:,1:3)~=0,2));

How would I locate non-zeros given a condition?

For example: A = [1 0 1 1 0 0 0 1 0 0 0 0]; rows = find(A(:,4) & sum(A(:,1:3)~=0,2));

29 days ago | 1

Answered

How to make statements intersect

a=[0 1 2]; b=[1 1 3]; if all(a==b) fprintf ('yes') else fprintf ('no') end

How to make statements intersect

a=[0 1 2]; b=[1 1 3]; if all(a==b) fprintf ('yes') else fprintf ('no') end

1 month ago | 1

| accepted

Answered

how to find size of scale bar on image

One approach would be: First, you need to segment the scale bar using any segmentation function, for example imbinarize (using ...

how to find size of scale bar on image

One approach would be: First, you need to segment the scale bar using any segmentation function, for example imbinarize (using ...

2 months ago | 0

Answered

Find the diameter of the parts in an image processing?

One approach would be: First, you need to segment the objects you want using any segmentation function, for example imbinarize,...

Find the diameter of the parts in an image processing?

One approach would be: First, you need to segment the objects you want using any segmentation function, for example imbinarize,...

2 months ago | 0

Answered

How to select the columns of a matrix which are a multiple of 5?

N = M(3,5:5:end)

How to select the columns of a matrix which are a multiple of 5?

N = M(3,5:5:end)

2 months ago | 0

Answered

Adding to the first value in a matrix based on the second value in that row.

Being A your matrix: A(A(:,2) == 11 | A(:,2) == 12,1) = A(A(:,2) == 11 | A(:,2) == 12,1) + 1

Adding to the first value in a matrix based on the second value in that row.

Being A your matrix: A(A(:,2) == 11 | A(:,2) == 12,1) = A(A(:,2) == 11 | A(:,2) == 12,1) + 1

2 months ago | 0

| accepted

Answered

Creating an array from 1 to n

n = 10 % 1:n ans = 1 2 3 4 5 6 7 8 9 10

Creating an array from 1 to n

n = 10 % 1:n ans = 1 2 3 4 5 6 7 8 9 10

2 months ago | 1

| accepted

Answered

How can I create n arrays of size 100 each with random integer values?

c = cell(1,100) for i = 1:100 c{i} = randi(100,1,100) end

How can I create n arrays of size 100 each with random integer values?

c = cell(1,100) for i = 1:100 c{i} = randi(100,1,100) end

2 months ago | 1

| accepted

Answered

Smoothing jumps when using unwrap()

You need to have a jump higher than pi to avoid the small jumps using unwrap (and this is not you case). Then, a trick you can d...

Smoothing jumps when using unwrap()

You need to have a jump higher than pi to avoid the small jumps using unwrap (and this is not you case). Then, a trick you can d...

3 months ago | 0

| accepted

Answered

How to separate a variable out of trigonomic expression

It is not a Matlab question, but you can do: cos(a+b)/sin(a+b) = 1/tg(a+b) = (1-tg(a)*tg(b))/(tg(a)+tg(b))

How to separate a variable out of trigonomic expression

It is not a Matlab question, but you can do: cos(a+b)/sin(a+b) = 1/tg(a+b) = (1-tg(a)*tg(b))/(tg(a)+tg(b))

3 months ago | 1

Answered

How to run a loop with different values and plot the result?

Yo can do it with an external loop with dt: for dt = 1:10 x=5; x_arr=[]; x_arr(1)=x; for i=1:10/dt ...

How to run a loop with different values and plot the result?

Yo can do it with an external loop with dt: for dt = 1:10 x=5; x_arr=[]; x_arr(1)=x; for i=1:10/dt ...

3 months ago | 1

| accepted

Answered

Integration fo function A(c) from -inf to +inf

A = @(c) sqrt(m/(2*pi*k*T1))*exp(-m/(2*k*T1)*(c-c_bar1)^2) q = integral(A,-inf,inf)

Integration fo function A(c) from -inf to +inf

A = @(c) sqrt(m/(2*pi*k*T1))*exp(-m/(2*k*T1)*(c-c_bar1)^2) q = integral(A,-inf,inf)

4 months ago | 0

| accepted

Answered

how do I append to an array within a loop with float values?

Try with this: k = 0:0.1:20; solutions = zeros(size(k)); for ii = 1:numel(k) a = -k(ii); b = -k(ii); soln= ...

how do I append to an array within a loop with float values?

Try with this: k = 0:0.1:20; solutions = zeros(size(k)); for ii = 1:numel(k) a = -k(ii); b = -k(ii); soln= ...

4 months ago | 0