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

1 year 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)

1 year 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

1 year 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));

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

1 year 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,...

1 year 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)

1 year 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

1 year 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

1 year ago | 2

| 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

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

1 year 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))

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

1 year 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)

1 year 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= ...

1 year ago | 0

Answered

Is it another command using to compare between vector and cell?

Then, to obtain the elements of U that doesn't exist in S, you can do: U = [1,2,3]; S = {1,2}; w = U(~ismember(U,cell2mat(S))...

Is it another command using to compare between vector and cell?

Then, to obtain the elements of U that doesn't exist in S, you can do: U = [1,2,3]; S = {1,2}; w = U(~ismember(U,cell2mat(S))...

1 year ago | 0

| accepted

Answered

How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?

n = 100; areatriangle = zeros(1,n) for ii = 1 : n areatriangle(ii) = .5*((ii/2)*ii); end or: areatriangle = .5/2*(1:n)...

How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?

n = 100; areatriangle = zeros(1,n) for ii = 1 : n areatriangle(ii) = .5*((ii/2)*ii); end or: areatriangle = .5/2*(1:n)...

1 year ago | 0

| accepted

Answered

How to find the position of points in a coordinate system?

Using for loops: R = zeros(numel(X),numel(Z)); for i = X for j = Z R(i,j) = sqrt(i.^2+j.^2); end end

How to find the position of points in a coordinate system?

Using for loops: R = zeros(numel(X),numel(Z)); for i = X for j = Z R(i,j) = sqrt(i.^2+j.^2); end end

1 year ago | 2

| accepted

Answered

position of values in a matrix

A = [23 24 35 2 12 19 24 23 12 15 26 17] loc = find(ismember(A,[35 2],'rows')) loc = 2

position of values in a matrix

A = [23 24 35 2 12 19 24 23 12 15 26 17] loc = find(ismember(A,[35 2],'rows')) loc = 2

1 year ago | 1

Answered

How to put a value in a plot label?

depth = [5,10,15,20]; for k = 1:4 kd = 0.0143.*5*k; SOTE = (a + kd + kp).*X.^beta.*5*k; figure(1) if k < 3 ...

How to put a value in a plot label?

depth = [5,10,15,20]; for k = 1:4 kd = 0.0143.*5*k; SOTE = (a + kd + kp).*X.^beta.*5*k; figure(1) if k < 3 ...

1 year ago | 0

| accepted

Answered

Why is this code not reading the csv file?

The images are useless, but the error is clear, your variable tdata doesn't exist. I guess you need to change this line: tdata ...

Why is this code not reading the csv file?

The images are useless, but the error is clear, your variable tdata doesn't exist. I guess you need to change this line: tdata ...

1 year ago | 0

Answered

ODE45, simple events

function [check,stop,direction]=landing(t,y) check = y; stop = 1; direction=0; end

ODE45, simple events

function [check,stop,direction]=landing(t,y) check = y; stop = 1; direction=0; end

1 year ago | 1

Answered

How to gracefully generate an all-one cell array?

function Output=OnesInCell(varargin) %This function should be the same as ones() except that each of the ones is packed into an...

How to gracefully generate an all-one cell array?

function Output=OnesInCell(varargin) %This function should be the same as ones() except that each of the ones is packed into an...

1 year ago | 0

| accepted

Answered

How to cut dimensions of 3d arrays in a cell.

Being A your cell array: newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)

How to cut dimensions of 3d arrays in a cell.

Being A your cell array: newA = arrayfun(@(i) A{i}(700:720,300:360,:),1:numel(A),'uni',0)

1 year ago | 1

Answered

selection of rows in a matrix

A = [36 13 9 21 23 32 35 5 3 43] B = A([1,3,5],:)

selection of rows in a matrix

A = [36 13 9 21 23 32 35 5 3 43] B = A([1,3,5],:)

1 year ago | 0

| accepted

Answered

Cannot call files named with ' character in the text

filename = '8''_Data_Startup-1234567489'

Cannot call files named with ' character in the text

filename = '8''_Data_Startup-1234567489'

2 years ago | 1

| accepted

Answered

Exporting data from matlab to a excel with a special pathway

xlswrite(filename,Y1,1) xlswrite(filename,Y2,2) xlswrite(filename,Y3,3)

Exporting data from matlab to a excel with a special pathway

xlswrite(filename,Y1,1) xlswrite(filename,Y2,2) xlswrite(filename,Y3,3)

2 years ago | 0

Answered

How do I code a function that's supposed to be an infinite pattern?

Another possibility: res = sum(x.*circshift(y,-1) - y.*circshift(x,-1))

How do I code a function that's supposed to be an infinite pattern?

Another possibility: res = sum(x.*circshift(y,-1) - y.*circshift(x,-1))

2 years ago | 0

Answered

Best way to calculate the determinants of a series of matrices?

delta = arrayfun(@(t) det(squeeze(G(t,:,:))),1:size(G,1));

Best way to calculate the determinants of a series of matrices?

delta = arrayfun(@(t) det(squeeze(G(t,:,:))),1:size(G,1));

2 years ago | 0