Answered

Interpolating at vertices of a mesh

In theory you cannot. A function that is piecewise constant on elements is discontinuos at the vertices and you cannot speak ab...

Interpolating at vertices of a mesh

In theory you cannot. A function that is piecewise constant on elements is discontinuos at the vertices and you cannot speak ab...

2 hours ago | 0

Answered

Obtain the mean angle (circle mean of a file)

angledata_deg is your angle data in degree meanangle_deg = rad2deg(atan2(mean(sind(angledata_deg),2),mean(cosd(angledata_deg),2...

Obtain the mean angle (circle mean of a file)

angledata_deg is your angle data in degree meanangle_deg = rad2deg(atan2(mean(sind(angledata_deg),2),mean(cosd(angledata_deg),2...

22 hours ago | 0

| accepted

Answered

How parentheses effects multiplication with pi ?

From wikipedia "While floating-point addition and multiplication are both commutative (a + b = b + a and a × b = b × a), they a...

How parentheses effects multiplication with pi ?

From wikipedia "While floating-point addition and multiplication are both commutative (a + b = b + a and a × b = b × a), they a...

1 day ago | 0

| accepted

Answered

Adding zeros to matrix

% Replace this with your image Image100 = peaks(100)+10; %Centering padding in 4 sides PadImage300 = zeros(300,300,size(Ima...

Adding zeros to matrix

% Replace this with your image Image100 = peaks(100)+10; %Centering padding in 4 sides PadImage300 = zeros(300,300,size(Ima...

1 day ago | 0

| accepted

Answered

How to create a surface with random spheres protruding?

Is this you want? x = linspace(0,1); y = linspace(0,1); [X,Y] = meshgrid(x,y); Z = zeros(size(X)); N = 30; for k=1:N ...

How to create a surface with random spheres protruding?

Is this you want? x = linspace(0,1); y = linspace(0,1); [X,Y] = meshgrid(x,y); Z = zeros(size(X)); N = 30; for k=1:N ...

1 day ago | 0

Answered

Integral calculation using matlab

Feel free to change these hyper-parameters n = 3 k = 2*pi*rand() integral(@(phi) arrayfun(@(phi) abs(integral(@(theta) exp(...

Integral calculation using matlab

Feel free to change these hyper-parameters n = 3 k = 2*pi*rand() integral(@(phi) arrayfun(@(phi) abs(integral(@(theta) exp(...

1 day ago | 0

| accepted

Answered

Combining function handles into one function handle

a = @(x) x(1)^2+x(2)^2; b = @(x) x(3)^2-x(4)^2; c = @(x) x(1)*x(4); % suppose your for-loop puts each function handle in a ...

Combining function handles into one function handle

a = @(x) x(1)^2+x(2)^2; b = @(x) x(3)^2-x(4)^2; c = @(x) x(1)*x(4); % suppose your for-loop puts each function handle in a ...

1 day ago | 0

Answered

I cannot find the distance between two matrices with respect to the Frobenius inner product.

Distance in frobenius scalar product: dist_AB = norm(A - B, 'fro') which is the same as this norm(A(:)-B(:),2)

I cannot find the distance between two matrices with respect to the Frobenius inner product.

Distance in frobenius scalar product: dist_AB = norm(A - B, 'fro') which is the same as this norm(A(:)-B(:),2)

1 day ago | 0

| accepted

Answered

Indexing problem with matrices

A = [3 5 9 6 ; 2 1 13 6 ; 6 8 52 4 ; 13 6 8 22 ]; GRID = [linspace(1,100,100); rand(1,100); rand(1,100)]' Code [tf,loc]=ismem...

Indexing problem with matrices

A = [3 5 9 6 ; 2 1 13 6 ; 6 8 52 4 ; 13 6 8 22 ]; GRID = [linspace(1,100,100); rand(1,100); rand(1,100)]' Code [tf,loc]=ismem...

2 days ago | 0

Answered

Convolution of to matrices

Example t1 = 0:2; A1 = [0.25 0.5 0.25]; t2 = [0 3 6]; A2 = [0.25 0.5 0.25]; Code for convolution vector Y (t,A) (I don't kn...

Convolution of to matrices

Example t1 = 0:2; A1 = [0.25 0.5 0.25]; t2 = [0 3 6]; A2 = [0.25 0.5 0.25]; Code for convolution vector Y (t,A) (I don't kn...

2 days ago | 0

| accepted

Answered

How do I turn of thr grid of a surface but keep the edge line on?

Just serve yourself with plot3 commands [X,Y,Z] = peaks; surf(X,Y,Z,'edgecolor','none'); hold on plot3(X(1,:),Y(1,:),Z(1,:),...

How do I turn of thr grid of a surface but keep the edge line on?

Just serve yourself with plot3 commands [X,Y,Z] = peaks; surf(X,Y,Z,'edgecolor','none'); hold on plot3(X(1,:),Y(1,:),Z(1,:),...

2 days ago | 1

Answered

Select points inside a polygon

Here is the code using POLYSHAPE load('Points.mat') load('polygon1_x.mat') load('polygon1_y.mat') lat = Points.lat; ...

Select points inside a polygon

Here is the code using POLYSHAPE load('Points.mat') load('polygon1_x.mat') load('polygon1_y.mat') lat = Points.lat; ...

2 days ago | 1

| accepted

Answered

Select points inside a polygon

But you already have the index in your code. here ... inon = in | on; % Combine .i...

Select points inside a polygon

But you already have the index in your code. here ... inon = in | on; % Combine .i...

2 days ago | 1

Answered

How to make a matrix of zeros and ones with a specific distance between each one?

dmin1=3; n=10; A=zeros(n); A(1:dmin1:end,1:dmin1:end)=1; disp(A)

How to make a matrix of zeros and ones with a specific distance between each one?

dmin1=3; n=10; A=zeros(n); A(1:dmin1:end,1:dmin1:end)=1; disp(A)

2 days ago | 0

| accepted

Answered

Algorithm to extract linearly dependent columns in a matrix

Test matrix (10 x 6) with rank 4 M = rand(10,4)*rand(4,6) Automatic selection of independent columns of M [Q,R,p] = qr(M,'vec...

Algorithm to extract linearly dependent columns in a matrix

Test matrix (10 x 6) with rank 4 M = rand(10,4)*rand(4,6) Automatic selection of independent columns of M [Q,R,p] = qr(M,'vec...

3 days ago | 2

Answered

Section an array into equal rows and changing simultaneously the values of each section.

Initial data >> M=randi(10,3,4) M = 1 3 9 4 6 10 3 4 8 8 5 6 ...

Section an array into equal rows and changing simultaneously the values of each section.

Initial data >> M=randi(10,3,4) M = 1 3 9 4 6 10 3 4 8 8 5 6 ...

3 days ago | 0

Answered

Call vector by key

Work for me >> M=containers.Map('KeyType','double','valueType','any') M = Map with properties: Count: 0 ...

Call vector by key

Work for me >> M=containers.Map('KeyType','double','valueType','any') M = Map with properties: Count: 0 ...

3 days ago | 0

| accepted

Answered

How I can find the index when both signals are high?

Assuming your signal are binary vectors of the same size b and r both = min(b,r); d = diff([0; both(:); 0]); upidx = find(d=...

How I can find the index when both signals are high?

Assuming your signal are binary vectors of the same size b and r both = min(b,r); d = diff([0; both(:); 0]); upidx = find(d=...

3 days ago | 1

| accepted

Answered

Polyfit with other model

Generate test data x=linspace(0,1,100) P = [rand(1,3) 1] y=polyval(P,x) + 0.1*randn(size(x)); Fit polynomial (order n) y=P(x...

Polyfit with other model

Generate test data x=linspace(0,1,100) P = [rand(1,3) 1] y=polyval(P,x) + 0.1*randn(size(x)); Fit polynomial (order n) y=P(x...

3 days ago | 0

Answered

create multiple submatrices from a large matrix

Probably better code using logical indexing M = rand(54,7056); [m,n] = size(M); pattern = circshift([true(1,9) false(1,7)],...

create multiple submatrices from a large matrix

Probably better code using logical indexing M = rand(54,7056); [m,n] = size(M); pattern = circshift([true(1,9) false(1,7)],...

3 days ago | 1

| accepted

Answered

create multiple submatrices from a large matrix

M = rand(54,7056); [m,n] = size(M); offset = 7; offset = mod(offset,16); I=(-16:8:ceil(n/8)*8+offset+8); J=-offset+(0:15)...

create multiple submatrices from a large matrix

M = rand(54,7056); [m,n] = size(M); offset = 7; offset = mod(offset,16); I=(-16:8:ceil(n/8)*8+offset+8); J=-offset+(0:15)...

3 days ago | 1

Answered

Is there any way to accelerate the solving of a series of large sparse positive definite linear equations "Ax=b" with same "A" and different "b"?

Two things come to my mind: Why can't you build all the b together then make a single inversion b = [b1 b2 ... bp] x = A \ b ...

Is there any way to accelerate the solving of a series of large sparse positive definite linear equations "Ax=b" with same "A" and different "b"?

Two things come to my mind: Why can't you build all the b together then make a single inversion b = [b1 b2 ... bp] x = A \ b ...

3 days ago | 0

Answered

How do i count same consecutive occurrences

Example: A=[1,1,1,1,1,2,2,2,2,3,3,3,3,2,2,2,1,1,1,1] Code d = diff([0, A==2, 0]); startidx = find(d==1) lgt = find(d==-1)-i...

How do i count same consecutive occurrences

Example: A=[1,1,1,1,1,2,2,2,2,3,3,3,3,2,2,2,1,1,1,1] Code d = diff([0, A==2, 0]); startidx = find(d==1) lgt = find(d==-1)-i...

3 days ago | 0

Answered

How to split a 3d matrix into sub-3d matrices?

probably you can use mat2cell IMO splitting a matrix in cell is rarely a good idea if you want your code works decenly in spee...

How to split a 3d matrix into sub-3d matrices?

probably you can use mat2cell IMO splitting a matrix in cell is rarely a good idea if you want your code works decenly in spee...

3 days ago | 0

Answered

Where has depfun gone? or How to make a dependency graph?

https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html https://www.mathworks.com/help/matlab/ref/matlab.c...

Where has depfun gone? or How to make a dependency graph?

https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html https://www.mathworks.com/help/matlab/ref/matlab.c...

3 days ago | 0

Answered

random matrix with a given number of specified elements

User inputs matsz = [3,3]; n1 = 4; % number of desired 1s, no need to specify for 0s Generate B = zeros(matsz); % + 0; B(r...

random matrix with a given number of specified elements

User inputs matsz = [3,3]; n1 = 4; % number of desired 1s, no need to specify for 0s Generate B = zeros(matsz); % + 0; B(r...

3 days ago | 1

Answered

How to find a row of a large matrix

It seems you run old MATLAB version without auto-expansion capability. This will work for any version: row = find(ismember(X,[...

How to find a row of a large matrix

It seems you run old MATLAB version without auto-expansion capability. This will work for any version: row = find(ismember(X,[...

3 days ago | 0

| accepted

Answered

How can one extract this vector from a matrix?

Avg = mean(reshape(M(:,2:3)',12*2,[])); [(1:length(Avg)); Avg]'

How can one extract this vector from a matrix?

Avg = mean(reshape(M(:,2:3)',12*2,[])); [(1:length(Avg)); Avg]'

3 days ago | 0