Answered
Distance between two points on the sphere.
Another formula of angle betwen two (3 x 1) vectors x and y that is also quite accurate is W. Kahan pointed by Jan here % test...

3 years ago | 0

Answered
Error in svd in r2018a
As Walter has pointed out, the workwaround given by TMW might be still flawed because it ignores the scale of A. A better solut...

3 years ago | 0

| accepted

Answered
[ ] or ( ) in constructing array
The only danger is that unexpected results when someone is careless about indentation and spacing a = 1 : 5 +2 b = [1 : 5 +2] ...

3 years ago | 2

Answered
How to fix infinity limit in the integral equation
Use integral function rather trapz % INITIAL CONDITIONS dtemp=1; finaltemp=1050; dt=(dtemp*60/3); H2O=0.023; CO2=0.00555; fp...

3 years ago | 1

| accepted

Answered
How do I reduce the running time when I call thousands of 'intlinprog' ?
You can try to call multiple problems at once by Concatenate f, intcon, b, beq, lb, yb, x0, Make matrices A, Aeq block diagon...

3 years ago | 0

Answered
How to find column where 0 turns to 1 for each row
load('egcolumnsep.mat'); c1 = find(strcmp(DATAb1.Properties.VariableNames,'Bins_1')); % == 10 % Extract relevant data A = t...

3 years ago | 1

| accepted

Answered
Looking for where line intersects on itself
If you interpolate your data by line segments it cross it selft at least 135 times data = readtable('data.csv'); xy=table2arr...

3 years ago | 0

| accepted

Answered
Should I use EIG or SVD to compute the eigenvalues of a symmetric matrix?
I always use EIG on SDP matrix, for the "same" reason that I use A\b preferable to (A'*A) \ (A'*b) to solve least square s...

3 years ago | 0

Answered
multiplication of matrix with long data
% Test data N = 4; Phi = 2*pi*rand(1,N); Theta = 2*pi*rand(1,N); Psi = 2*pi*rand(1,N); X = rand(1,N); Y ...

3 years ago | 1

| accepted

Answered
set unique values in matrix for each column new to 0
Another solution without assum^tion of M is sorted by column M = randi(4,10,3) [m,n]=size(M); [S,i] = sort(M); M(i+(0:n-1)...

3 years ago | 0

Answered
set unique values in matrix for each column new to 0
This works for repeated elements that are in any order in the columns M = randi(4,10,3) [m,n]=size(M); IJ = cell(n,1); v =...

3 years ago | 0

Answered
set unique values in matrix for each column new to 0
It looks like your repeated elemenst are adjacent M = [0 0 0 ; 0 0 1; 1 0 2 ; 2 1 3 ; 2 2 4 ; 2 2 4] M.*(diff([nan(size(M(1,:)...

3 years ago | 0

Answered
How to determine eigenvalues and eigenvectors?
A=[3,9;3,5] B=[2,0;0,8] [V lambda] = eig(A,B,'vector') % here is the first eigen vector with lambda(1) the corresponfing ...

3 years ago | 0

| accepted

Answered
How can I repeat a 2-D array to create a 3-D array?
A =[1 2 3;4 5 6]; B = repmat(reshape(A, [1 size(A)]),[5 1 1])

3 years ago | 0

| accepted

Answered
R2022a Compatibilty with W10 1809 LTSC
I run MATLAB R2020a on Windows 8 without any issue.

3 years ago | 0

Answered
Using regular expressions to recognize pattern based on multiple lines
Two consecutive lines is a string separate by one newline character: s = sprintf('G2 yyyy \nG0 blabla \nG1 xxx') regexp(s,'G0....

3 years ago | 0

Answered
Perform mldivide between 3x3 matrix M and every RGB pixel in a image in GPU
B = reshape(reshape(I,[],3)*inv(M.'),size(I));

3 years ago | 0

Answered
find 'last' function not working
Beside using 'any'/'all', you might make two modifications to get what you want [Monotonic_last_row, ~] = find(~isnan(Monotonic...

3 years ago | 1

Answered
How to create a simple matrix from two different kind of matrix size ?
M1 = rand(2,5,2) ; M2 = rand(2,5) ; reshape(cat(3,M1,M2),size(M1,1),[])

3 years ago | 1

| accepted

Answered
Alternative to using Multi-level field struct
It seems you just burry an array into nested structures for no apparent reason other than using struct with a fieldname for a sa...

3 years ago | 1

Answered
Order Matlab not to continue until the external run is completed
% delete the 'result.csv' system('remove result.csv') % add the appropiate path to csv file % launch your fluent software sy...

3 years ago | 1

| accepted

Answered
Why matrix division returns different answers?
When you have a underdetermined linear system, meaning you "solve" A*x = b where A has non-zero kernel, or in other word nul...

3 years ago | 1

Answered
Why does MATLAB Compiler issue a warning regarding "startup.m" adding paths?
Turn off the warning warning('off','Compiler:compiler:COM_WARN_STARTUP_FILE_INCLUDED') You might put it in your startup.m so t...

3 years ago | 4

Answered
How to replace unique interval of columns in each row of a matrix with zero?
A1= [1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 1 1...

3 years ago | 0

| accepted

Answered
All possible path between two points
allpath introduced in R2021a will do. For older release I posted a code here

4 years ago | 0

Answered
Is there a reason why row vectors are default in Matlab?
Beside an historical reason to me it seems it related to for the for-loop is designed to work For M a true matrix for v = M ...

4 years ago | 0

Answered
Script using parfor spawns way too many threads
It sounds count productive to cut off the low-level multi-thread and move it on you parfor loop. I rather split the parfor into...

4 years ago | 0

Answered
vertical or horizontal array random combination in single array
A={[12;13] ;[1,5] ;[5;6;7]; [1,3,5,4]}; B = cellfun(@(x) x(:), A, 'unif', 0); C = cat(1,B{:})

4 years ago | 0

| accepted

Answered
Reorder symmetric adjacency matrix
p is your order, A is the adjadcent matrix p = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]; Areorder = A(p,p)

4 years ago | 0

Question


Parallel pool on function that uses persistent variables
Obviously parallel computing cannot handle correctly persistent variable, as showed in this minima example. It seems when runin...

4 years ago | 2 answers | 0

2

answers

Load more