Answered
How to match last point of the previous coordinate with the next point of the next coordinate?
Test data dict{1} = [ 24 13; 8 21 ]; dict{2} = [ 2 17; 13 21 ]; dict{3} = [ 17 1; 21 12; 22 15; 21 24; 18 29 ]; dict{4} = [ ...

5 years ago | 1

Answered
count occurrences of string in a single cell array (How many times a string appear)
[yy,~,i] = unique(xx,'stable'); count = accumarray(i(:),1,[numel(yy),1]);

5 years ago | 1

Answered
How to calculate the area average of data
"The formula of the area average is = intregation (vorticity*dA)/A" Then the result is simply >> mean(vor2d,'all','omitnan') ...

5 years ago | 0

Answered
Undefined function or variable 'fabs'
Replace fabs(delta_h) < 0.6*raio_elipsoide with abs(delta_h) < 0.6*raio_elipsoide % or -delta_h < 0.6*raio_elipsoide It seem...

5 years ago | 0

Answered
How to make a for faster?
ix = ismember(idx_x(:),x(:)); iy = ismember(idx_y(:),y(:)); ixy = ix & iy; idx = 1:18:size(ixy,1); altura_raio_direto = heig...

5 years ago | 0

Answered
What are the files needed for creating standalone .exe files from GUI?
You need MATLAB Compiler

5 years ago | 0

| accepted

Answered
How to I find X unique combinations (order doesn't matter) of X numbers within an array of X numbers.
You might just miss the feature of NCHOOSEK that can accept the vector array as input >> X=rand(1,5) X = 0.3566 0....

5 years ago | 1

| accepted

Answered
How to add to create matrix by combining two columns
newMat = [newCol, h]

5 years ago | 0

Answered
Error Plotting values from a struct with fields
plot(struct2array(solarData.outputs.avg_dni.monthly)) You can do the label using Walter's solution

5 years ago | 0

Answered
Plot cross tangent of two circle
% Generate two random circles boxsize = 10; % center circle 1 x1 = boxsize*rand; y1 = boxsize*rand; % center circle 2 x2 =...

5 years ago | 0

Answered
problems using for loop
Both codes are flawed, this statement is flawed (neverr compare floating points with "==") if mod(t(1,k),Ts) == 0 You should r...

5 years ago | 0

Answered
Combine two vectors together
a(1:2:2*end-1) = a; a(2*(1:length(b))) = b

5 years ago | 1

Answered
flatten structure array if values are identical
You can use SERIALIZE de DESERIALIZE MATLAB objects before taking UNIQUE. I use https://www.mathworks.com/matlabcentral/fileexc...

5 years ago | 0

| accepted

Answered
Create new array with repeated values (error k must be less than or equal to N)
new_thick = org_thick(randi(end,1,8))

5 years ago | 0

Answered
Logical Indexing instead of loops in 3D-Matrices
This is code according to the specification stated in the question, NOT the example that is incoherent. % Dummy test data AB1=...

5 years ago | 1

| accepted

Answered
How do I assign values to a matrix?
a=zeros(size(stability)); b=zeros(size(stability)); d=zeros(size(stability)); e=zeros(size(stability)); ind=find(stability...

5 years ago | 0

| accepted

Answered
Finding the number of rows to the next row containing a 1
Now I just discover CUMSUM has direction option, this is based on Rik's cumsum method, but avoid the double flipping. B = ones...

5 years ago | 2

Answered
How to Change only certain Values in a matrix with a different vector?
B(1:20,:) = repmat(A,[20 1]) or B(1:20,:) = repmat(A,20,1) or B(1:20,:) = repelem(A,20,1)

5 years ago | 0

| accepted

Answered
use of ismember command and change of corresponding
AB=[2 5 8; 1 6 1]' DE=(1:10)'*[1 0] HI=DE; [tf,loc]=ismember(HI(:,1),AB(:,1)); tf=tf&HI(:,2)==0; HI(tf,2)=AB(loc(tf)...

5 years ago | 0

| accepted

Answered
How to enlarge an image using spline interpolation
A=peaks(10); B=interp2(A,1,'spline'); subplot(1,2,1) imagesc(A) subplot(1,2,2) imagesc(B)

5 years ago | 0

Answered
How to find unique group of numbers?
I propose do it this way: % Test example C{1} = [1; 3; 4]; C{2} = [3; 9; 135; 278]; C{3} = [6; 89; 256; 803; 6987; 2356]; C...

5 years ago | 0

| accepted

Answered
Apply a formula and create a new matrix
b.'*sum(A,2) sum(A,2).'*b % preferable than sum(A.'*b) % or sum(b.'*A) % or sum(A.*b,'all') or s = 0; for i=1:size(A,1) ...

5 years ago | 0

| accepted

Answered
Remove rows duplicates based on a condition
A=[ ... 12178 -5.22911 -37.2923 20.5000 3000; 12672 -5.17523 -37.2833 21.5000 3000; 12178 -5.22911 -37.2923 20.5000 4000; 12...

5 years ago | 0

Answered
Why is det(A) sometimes =/= det(A') for random square matrices
Nobody told you ever compare floating point using "==", "isequal", "ismember()"? % Preallocating and Setting Reps NReps=1000; ...

5 years ago | 0

| accepted

Answered
inverse of complex matrix
Yes if you have badly conditioned (or badly scaled), or practically singular matrix. Usualy you get a warning message when compu...

5 years ago | 1

| accepted

Answered
Can this problem be expressed as a MILP problem?
"The tricky part is that V is also equal to E(x)+R*I(V) and has one unique value." Can we then assume this value is V(i) and kn...

5 years ago | 0

Question


Vectorization time-varying recursive linear function
I try to vectorize this simple recursive relation (all quantities are scalars) x_{0} = 0; x_{n} = x_{n-1}*a_{n} + b_{n} for n=...

5 years ago | 1 answer | 0

1

answer

Answered
Finding the number of rows to the next row containing a 1
As much as I love vectorization, this problem is a typical case where the for-loop method is easier, faster, more readable. Thi...

5 years ago | 2

Answered
Fast method for findings which rows of a matrix are contained in another
Not know how much my code is faster than ISMEMBER (which IMO pretty fast) (EDIT: it's indeed > 3 time faster) % Generate random...

5 years ago | 1

Answered
Is there a metric for computing the "scale" between two polygons?
scale = sPG.perimeter/PG.perimeter

5 years ago | 0

Load more