Réponse apportée
How to simplify this and make it efficient
NOTE: what a messy and bad data structure. There might be a much better way than working cell of structs and table. % Generate...

presque 7 ans il y a | 2

| A accepté

Réponse apportée
How to calculate all permutations of a vector that satisfy a given condition
If your vector is consecutive number, you can directly use this allVL1 in the File Exchange. Otherwise you can adapt the subfun...

presque 7 ans il y a | 2

| A accepté

Réponse apportée
how to do left and right bit rotation
% Test example, 166 corresponds to your example of binary '10100110' M=[2 32 45; 3 54 166; 134 245 69] rotfun = @(M...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Best way to calculate the determinants of a series of matrices?
I reverse the order and put the page in third dimension (avoid to use squeeze). For small size, you can save CPU time by 4 fold...

presque 7 ans il y a | 2

| A accepté

Réponse apportée
How to 2D plot using the equation of fi and zi?
The wikipedia page plots only the polar sector 2*pi/(2*n) of the stream lines / potential The second plot is the full picture....

presque 7 ans il y a | 0

| A accepté

Réponse apportée
reshape 3d to 2d array
Not RESHAPE, but PERMUTE (there is movement in internal storage, and it more expansive than RESHAPE) A = permute(A, [3 2 1]);

presque 7 ans il y a | 1

Réponse apportée
How to set a range for a random 4x3 Matrix
In principle it can reach -10/+10 with tiny strict positive probability, but won't cover interval with a fine density x = ((ran...

presque 7 ans il y a | 0

Réponse apportée
How to set a range for a random 4x3 Matrix
Inclusive and float x = max(min(((rand(4,3)-0.5)*20)*1.001,10),-10) you get 1/1000 chance to hit -10/+10

presque 7 ans il y a | 0

Réponse apportée
Joint Histogram 2 D
% Test data A = imread('ngc6543a.jpg'); red=A(:,:,1); green=A(:,:,2); h = accumarray([green(:),red(:)]+1,1,[256 256]);

presque 7 ans il y a | 0

Réponse apportée
Joint Histogram 2 D
% Test data A = imread('ngc6543a.jpg'); red=A(:,:,1); green=A(:,:,2); % h = histcounts2(green,red,256); % compute % or pl...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Generate random Bistochastic matrix with zero diagonals
For small n (up to 7/8), use RANDFIXEDSUM function on FEX n = 5; % size of matrix % This must be done once if n doesn't chan...

presque 7 ans il y a | 0

Réponse apportée
Finding the common range between two ranges
You can use this RangeIntersection function on FEX % Test data X1=[0.316227766016838 0.346410161513775 0.509901951359279 0.52...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
minimiztion the distance travel
Checkout function distances Warning : Your adjacent matrix is not symmetric ! >> A A = 0 2 100 2 10 ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How to use randperm with minimum spacing between random numbers
n=20; k=3; b=7; [as,is]=sort(randperm(n-(k-1)*(b-1),k)); % if it throws an error then b/k/n are not compatible a = as + (0...

presque 7 ans il y a | 2

Réponse apportée
Find series of maxima of array (and matrix) within blocks of size n
maxfun = @(A) squeeze(max(reshape(A,size(A,1),5,[]),[],2)); A = [1 2 5 1 0 0 5 0 1 2 4 0 5 3 2 0 1 0 0 5] B = maxfun(A) ...

presque 7 ans il y a | 1

Réponse apportée
How to sum matrices together when within a structure
linear_RL_broadband = sum(cat(3,linear.linear_RL_sum),3)

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How to calculate the average gradient of an image?
AG=abs((sum(sum(mode(Gmag))/(sqrt(2))))) I can't see the denominator factor (H-1)*(W-1). And Why you use MODE? Those two error...

presque 7 ans il y a | 0

Réponse apportée
make header from numeric array
hdr = arrayfun(@(x) sprintf('L_conv_%f', x), wl_arr, 'unif', 0)

presque 7 ans il y a | 0

| A accepté

Réponse apportée
matrix to cell convert?
Depending on what you want as organization, either C = mat2cell(reshape(A,4*64,4*64),4*ones(1,64),4*ones(1,64)) or C = reshap...

presque 7 ans il y a | 2

Réponse apportée
Matlab fit to three dimensions function
n = length(y); A = [ones(n,1) x1(:) x2(:) x3(:) x1(:).^2 x2(:).^2 x3(:).^2 x1(:).*x2(:) x1(:).*x3(:) x2(:).*x3(:)] \ y(:)

presque 7 ans il y a | 0

Réponse apportée
Solving a set of linear equations using vectorization
P = 40000; dP = 0:10:40 % what ever z = zeros(size(dP)); A = [1 1 1;10 28 40;144 -240 180]; B = [-P+z; -dP; z]; F = A \ B

presque 7 ans il y a | 0

Réponse apportée
3D Array Multiplication with 2D Matrix
Simply do (R2016b or later) data1 = data1 .* data2(:)

presque 7 ans il y a | 1

Réponse apportée
Use of cellfun to obtain the 2 element ONLY
>> c={'A1' 'A2' 'A3' 'A4' ''} c = 1×5 cell array {'A1'} {'A2'} {'A3'} {'A4'} {0×0 char} This throw a...

presque 7 ans il y a | 0

Réponse apportée
how to stack 2 dimensional arrays into 3 dimensional aarays?
If 2D arrays are stored in 9 variables cat(3,A1,A2,A3,A4,A5,A6,A7,A8,A9); If they are stored in 1x9 cell C cat(3, C{:});

presque 7 ans il y a | 2

| A accepté

Réponse apportée
Unable to use xlsread to open a file
for i=1:10 fil_length= xlsread(['\\some_pathway_here\Filament_Length_Dat\Filament_Length_' num2str(i) '.xls']) end

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Forward, backward and central differences
dt=1/500; for k=1:length(Fish) Fish(k).velocity1 = gradient(Fish(k).position1,dt); Fish(k).velocity2 = gradient(Fish(...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
How to detect the centre of four image points?
The "center" surely is the intersection of two lines passing by the two pairs of opposite circle center. So I propose you to fi...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
What is the difference between 5 and '5'
The '5' is the char array. Char array contain a text including number, such as 'Schrodinger has 2 dogs and 1/2 cat'. Char array ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Problem with Cholesky's decomposition of a positive semi-definite matrix
M=LDL’. If someone could tell me how to adapt this function to return the matrix R instead of L and D I would be extremely thank...

presque 7 ans il y a | 2

Réponse apportée
Add or subtract 0.1 randomly to all elements of a matix
A + 0.1*(2*(rand(size(A))>0.5)-1) or A + 0.1*(2*(randi([0,1],size(A)))-1)

presque 7 ans il y a | 1

| A accepté

Charger plus