Réponse apportée
Do I need to initiate the parallel computing toolbox for my code to run on multiple cores?
MATLAB has many low level functions are multi-thread coded and potentially use all the CPU core. In this case parallel tbx wil...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Speeding up to find minimum value using min() function
Alternative way % Fake data c=cumsum(rand(1,10000)); s=c(end)*rand(1,10000); cpad = [-Inf c Inf]; b = discretize(s,cpad);...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Can we compute the graph Laplacian matrix for a directed graph?
In this thread I give formula for graph, for digraph you just need to be careful about indegree or outdegree % TMW example s ...

plus de 4 ans il y a | 1

Réponse apportée
Which solver should I use to solve a square and symmetric, linear system of equations?
Don't worry, MATLAB backslash detects automatically the type of your matrix and adapt the method. See "Algorithm" of doc page h...

plus de 4 ans il y a | 1

Réponse apportée
How can the following code be optimized / vectorized?
It takes about 25 seconds only PC Ac35 = A(:,3:5); Ai = reshape(Ac35,[],1,3); B = zeros(SitesInSystem,SitesInSystem); for j=...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How to extract the coordinates of points/vertices in a curve?
clear MeshSize = 0.04; LensStr = 'osci'; radius = 1; %% n = ceil(radius/MeshSize); % radial resolution [X,...

plus de 4 ans il y a | 2

Réponse apportée
How to generate a matrix with entries of -1 and +1 of size N x M where all the columns are unique ?
N = 3; M = 5; A = (dec2bin(randperm(2^N,M)-1,N)-'0')'*2-1

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Obtain the sorted index vector
Use the second output of sort x=[0.5; 0.4; 0.6; 0.9] [y,z] = sort(x,'descend')

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Reversing a vector in the same line of code
a_vec = [2, 4, -5, 7, 18, 0] flip(a_vec)

plus de 4 ans il y a | 1

| A accepté

Réponse apportée
what is the efficient way to search for value in a large struct
You structure array seems to be linear, I would store the data in a structure of (cell) arrays rather than array of structures. ...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
About "ismember" function
No loop or arrayfun is needed Var1=["AAA" "AA" "A" "BBB" "BB" "B"]'; Var2=[1 2 3 5 7 13]'; PD=table(Var1,Var2) Var1=["B" "...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
I have many structs (from an XML file) with some common and different fields. How can I add the missing fields to each struct automatically so that all have the same fields?
I don't read you description, just to post here my tool catstruct s1=struct('a',1,'b',2); s2=struct('b',3,'c',4); s3=struct('...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Generate a series of random integers but with consecutive numbers including
A=ones(4,6); A(1,:)=ceil(10*rand(1,size(A,2))); R=reshape(cumsum(A(:)'),size(A)); R=R(:,randperm(end)); R=R(:)'

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Can this for loop be vectorized?
e_i_h_reshape = reshape(e_i_h,N_i,1,N_draws); alpha_i_h_t = e_i_h_reshape + e_h * t;

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
Why trust-region-reflective algorithm in fmincon require a gradient as input?
I don't think Matt's answer is correct, rather Torsen answer is better. The Trust region algorithm must approximate the objectiv...

plus de 4 ans il y a | 0

Réponse apportée
Nearest Neighbor Matching without Replacement
If you have R2019a release x=rand(1,10) y=rand(1,10) C=abs(x(:)-y(:).'); M = matchpairs(C,max(C(:))); px = M(:,1); xm ...

plus de 4 ans il y a | 0

Réponse apportée
Obtaining half-spaces from the convex hull in MATLAB
% k = convhull(P), the half spaces form is {x such that A*x <= b} with W=P(k,:); V=W(1:end-1,:); A=(W(2:end,:)-V)*[0 -1; 1 0]...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
How can I sort intersections points given from polyxpoly according to order of appearence?
Some modifications based on this FEX x = cumsum(rand(1,10)); % Generate random P1 and P2 x = x/max(x); y = rand(size(x)); ...

plus de 4 ans il y a | 1

| A accepté

Réponse apportée
How do I find if the three arrays of unequal size have the same values?
Use FEX mintersect i1 = [1 3 4]; i2 = [4 4 2 5]; i3 = [5 4 1 5 3 3 2]; mintersect(i1, i2, i3)

plus de 4 ans il y a | 0

Réponse apportée
Generating n bit random numbers with each bit sampled N times.
n=8; % number of bits r=10; % number of bit repetitions, 100 in your case m=20; % number of sequenes (>=r) i=zeros(r,n); for...

plus de 4 ans il y a | 0

Réponse apportée
Solving constrained optimization problem
A=randn(6,2) [h,lambdamin] = svds(A.',1,'smallest')

plus de 4 ans il y a | 1

Réponse apportée
Matlab order of operators
"`C\D'` should be equal to finding the `x` s.t. `C=(D')*x`." No. Rather D' = C*x Your code should be while true C =...

plus de 4 ans il y a | 0

Réponse apportée
How does 'unique' work under the hood (in general terms)
If I have to implement unique, I would implemented by sorting the find the difference similar to this a=randi(10,1,100); % u i...

plus de 4 ans il y a | 1

| A accepté

Question


sum on empty arrays
Can someone explain the logic of third statement (Run under R2021b) : sum(zeros(0,0)) sum(zeros(1,0)) sum(zeros(2,0)) % This ...

plus de 4 ans il y a | 1 réponse | 0

1

réponse

Question


Tiff class: Tile setting
I'm confused in setting two parameters TileLength and TileWidth for Tiff object when my data is an 3D array (m x n x p). In the...

plus de 4 ans il y a | 1 réponse | 0

1

réponse

Réponse apportée
Vectorizing loop containing multiplication of a scalar and a matrix
w = [0.2,0.5,1,0.5,0.2]; i=reshape(1:length(w),1,1,[]); z = zeros(size(i)); s=sum([i-1, i, 0+z; i, i+1, 0+z; 0+z, 0+z, 1+z].*...

plus de 4 ans il y a | 0

| A accepté

Réponse apportée
mldivide (backslash): advantage by using sparse matrix instead of a full matrix with respect to the quality of the results?
If your condition is 3.65e27 you wi=on't get any reliable solution regardless the method. The full matrix use QR with permutati...

plus de 4 ans il y a | 3

Réponse apportée
histc vs. histcouns
The result differ by the way the last bin is handed in both function. To get the same result you must change the last edge to In...

plus de 4 ans il y a | 1

| A accepté

Réponse apportée
2×2 matrix
c=cell(2*2,1); [c{:}]=ndgrid(1:8); a=reshape(cat(5,c{:}),[],2,2); a=permute(a,[2 3 1]); disp(a)

plus de 4 ans il y a | 0

Réponse apportée
Cholesky factorization: How to change code to produce A = L' * D * L instead of A = L * D * L' .
% Generate random symetric A A=randn(5); A=A'+A; disp(A) [L,D]=ldl(A); disp(L*D*L') [L,D]=ldl(rot90(A,2)); L=rot90(L,2)...

plus de 4 ans il y a | 0

| A accepté

Charger plus