Respondida
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...

más de 4 años hace | 0

| aceptada

Respondida
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);...

más de 4 años hace | 0

| aceptada

Respondida
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 ...

más de 4 años hace | 1

Respondida
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...

más de 4 años hace | 1

Respondida
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=...

más de 4 años hace | 0

| aceptada

Respondida
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,...

más de 4 años hace | 2

Respondida
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

más de 4 años hace | 0

| aceptada

Respondida
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')

más de 4 años hace | 0

| aceptada

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

más de 4 años hace | 1

| aceptada

Respondida
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. ...

más de 4 años hace | 0

| aceptada

Respondida
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" "...

más de 4 años hace | 0

| aceptada

Respondida
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('...

más de 4 años hace | 0

| aceptada

Respondida
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(:)'

más de 4 años hace | 0

| aceptada

Respondida
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;

más de 4 años hace | 0

| aceptada

Respondida
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...

más de 4 años hace | 0

Respondida
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 ...

más de 4 años hace | 0

Respondida
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]...

más de 4 años hace | 0

| aceptada

Respondida
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)); ...

más de 4 años hace | 1

| aceptada

Respondida
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)

más de 4 años hace | 0

Respondida
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...

más de 4 años hace | 0

Respondida
Solving constrained optimization problem
A=randn(6,2) [h,lambdamin] = svds(A.',1,'smallest')

más de 4 años hace | 1

Respondida
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 =...

más de 4 años hace | 0

Respondida
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...

más de 4 años hace | 1

| aceptada

Pregunta


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 ...

más de 4 años hace | 1 respuesta | 0

1

respuesta

Pregunta


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...

más de 4 años hace | 1 respuesta | 0

1

respuesta

Respondida
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].*...

más de 4 años hace | 0

| aceptada

Respondida
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...

más de 4 años hace | 3

Respondida
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...

más de 4 años hace | 1

| aceptada

Respondida
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)

más de 4 años hace | 0

Respondida
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)...

más de 4 años hace | 0

| aceptada

Cargar más