Answered
Why the results are different while using eig() to solve syms and double Jacobian matrix?
If I ask a set of 3 integer numbers > 1 so that 30 is the product, what do you tell me? (5,3,2) or (5,2,3) or (3,5,2) or (3,...

2 years ago | 1

| accepted

Answered
how to enable mex -setup for newer compiler (Visual Studio 2022) on older MATLAB (R2018a) ?
Go to bin\win64\mexopts under matlabroot folder Select one of the xml file (most recent supported MSVS C/C++) Copy it there, r...

2 years ago | 0

Answered
compare char (and empty elements) present in two cells
replace the problematic command with tf = strcmp(char(A),char(B));

2 years ago | 0

| accepted

Answered
Is there a way to constrain polyfit?
x = 10+cumsum(rand(1,10)); y = (1+rand())*(x-min(x)).^2; y = y + 2*randn(size(x)); % For 2nd order polynomial P = polyfi...

2 years ago | 1

| accepted

Answered
Splitting numbers of vector in multiple parts
V = [2022024 2023074 2022044 2023014 2023054] s = string(V)'; s = [extractBefore(s,5) extractAfter(s,4)]

2 years ago | 0

Answered
How to sample single values from field in *non-scalar structure array*?
Just shorter code, not necessary better. A = repmat(struct('mat',speye(3)),10,1); for k = 1:10 A(k).mat = A(k).mat * k; ...

2 years ago | 1

Answered
determine the coordinates with the 0's within a cell
Why storing scalars in cell and not in matrix? It is very inefficient. load matrix check_1 [i,j]=find(cellfun(@(x) isequal(x,...

2 years ago | 0

| accepted

Answered
Splitting numbers of vector in multiple parts
If numerical value output is desired V = [2022024 2023074 2022044 2023014 2023054] [floor(V/1000); mod(V,1000)]'

2 years ago | 1

Answered
Splitting numbers of vector in multiple parts
If string output is desired V = [2022024 2023074 2022044 2023014 2023054] c = mat2cell(char(arrayfun(@num2str,V,'unif',0)),o...

2 years ago | 0

| accepted

Answered
Calculate eigenvalues in certain range for very large sparse matrices
Not directly but you can use deflation technique omegamid = mean([omega0 omegaf]); k = 10; % adjust E = eigs(K, M, k, omegami...

2 years ago | 1

| accepted

Answered
compare two matrices with isequal
A single call of isequal on the top level is OK. Note that is you have NaN somewhere in your data, isequal will fail to detect ...

2 years ago | 0

| accepted

Answered
Efficiently moving values in a 3-dimensional array
I'm with Matt on permuting your data. I recommend not moving data around but rebuild a new array, since I suspect some deep copy...

2 years ago | 1

Answered
Angle between a vector and xy, xz, and yz planes
P1=[12,14,78] xyzc=num2cell(eye(3),1) [x,y,z]=deal(xyzc{:}); rad2deg(subspace(P1(:),[x y])) rad2deg(subspace(P1(:),[x z]))...

2 years ago | 2

Answered
How can I add new cells with NaNs to a matrix
This code inserts the NaN to array (and not replace existing elements) at the given positions. Note the original array must hav...

2 years ago | 3

| accepted

Answered
How vectorize this loop
repmat is not needed (thanks to auto expension) columns = 8; a = magic(columns); b = [15, 7, 3, 4, 9, 0, 9, 4]; % ====> 0 is...

2 years ago | 0

| accepted

Answered
import to the workspace a .mat file saved in a folder other than pwd
folder = 'C:\Users\Desktop\folder_test'; file = 'test.mat'; load([folder filesep() file])

2 years ago | 0

Answered
Difference between mldivide and lsqr
The difference manifests obviously when you try to solve underdetermined linear system A*x = b. A=rand(3,5) b=rand(3,1) The b...

2 years ago | 1

| accepted

Answered
transform an empty matrix '0x0 double' into a matrix '0x2 double'
test_p = importdata("test_p.mat") ir = cellfun('size',test_p,1)==0 & cellfun('size',test_p,2)==0 test_p(ir) = {zeros(0,2)}

2 years ago | 0

| accepted

Answered
how set diagonal =1 in matrix tridimensional a(:,:,:)
% Generate dummy test data a = 0.01*rand(2,3,4) [b,c,d] = size(a); a(1+(b+1)*(0:min(b,c)-1)'+b*c*(0:d-1)) = 1; a

2 years ago | 0

Answered
how set diagonal =1 in matrix tridimensional a(:,:,:)
% Generate dummy test data a = 0.01*rand(2,3,4) [b,c,d] = size(a); [I,K] = ndgrid(1:min(b,c),1:d); a(sub2ind([b,c,d],I,I,K...

2 years ago | 0

Answered
How to check the degree of parallelism
I'm not sure, but it looks like you might take a look at subspace command

2 years ago | 0

Answered
Find the rows of a matrix A within another matrix B
Use ismember command with 'row' option % Generate some dymmy date for testing B=randi(4,10,2) A=randi(4,10,2) % Engine B_ne...

2 years ago | 0

| accepted

Answered
Finding valid sequences in a list based on specific conditions in matlab
See if the results are what you expect (if not please explain why) getvalidseq({'Rain' 'Cloud' 'Sun' 'Sun' 'Sun' 'Sun' 'Sun' 'S...

2 years ago | 0

| accepted

Answered
How to segment a curve into linear and nonlinear pieces
Ths produces kind of "arbitrary" choice of the breakpoint, consider fitting the global curve with few line segments load(websa...

2 years ago | 0

Answered
How do I locate the most repeated elements in an array/vector?
a = [1 1 1 0 1 1 0 2 2 2]; i = find([true diff(a)~=0 true]); n = diff(i); j = find(n == max(n)); b = a(i(j))

2 years ago | 1

Answered
How to find the closest value pair in a matrix?
For A that has at least 3 rows and the closest in the sense of l2 norm (auclidian distance), without the need of toolbox. But i...

2 years ago | 0

Answered
How to vectorize the multiple loops
Warning code not tested for correctness: EDIT correctness is now check % set up the initialization params a_b = 4;% max 8 h ...

2 years ago | 1

| accepted

Answered
How can I obtain all possible combinations of 3 decimals whose sum equals 1, without running into memory and space issues?
Use my FEX https://www.mathworks.com/matlabcentral/fileexchange/17818-all-permutations-of-integers-with-sum-criteria The array ...

2 years ago | 1

Answered
Memory problems with Cell Array mex file
Another potential issue is your cell does not contain double as assumed. In this case double* ptr = mxGetPr(cell); and later...

2 years ago | 0

| accepted

Answered
Difference between 2 orientations
I recall a long discussion with Roger, James on this topic on the newsgroup long time ago. At the time our conclusion is quate...

2 years ago | 0

Load more