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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

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

mehr als 4 Jahre vor | 1

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 2

Beantwortet
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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 1

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 1

| akzeptiert

Frage


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

mehr als 4 Jahre vor | 1 Antwort | 0

1

Antwort

Frage


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

mehr als 4 Jahre vor | 1 Antwort | 0

1

Antwort

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

mehr als 4 Jahre vor | 0

| akzeptiert

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

mehr als 4 Jahre vor | 3

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

mehr als 4 Jahre vor | 1

| akzeptiert

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

mehr als 4 Jahre vor | 0

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

mehr als 4 Jahre vor | 0

| akzeptiert

Mehr laden