Put the various v into a matrix and use eye () to. Then just repeat with a scrambled x and y - Im sure there is some function for that. v zeros (1, length (X)) for k 1 : length (X) row Y (k) col X (k) v (k) m (row, col) end. (The last output is the new sparse-matrix display format in Julia 1.6. You can do this, where m is your matrix, and v is the vector of extracted values from the x,y locations. Here, I’m using the broadcasting “dot” operator. It is written in a vectorized fashion in MATLAB. The code is a bit simpler if you have an array of arrays B, where each element B is a vector (of the correct length) of the entries on diagonal i: spdiagm(1000,1000, (d. To make a diagonal matrix or to get the diagonal entries of a matrix, you can use the diag () function in MATLAB. The following gives the diagonal matrix D whose diagonal is the vector vec. Note that Matlab’s Bin is a bit odd because Matlab only uses part of each column Bin depending on the diagonal d, whereas Julia expects a vector of the correct length for the corresponding diagonal. D diag (v,k) places vector v on the k th diagonal. you can emulate the Matlab syntax A = spdiags(Bin,d,1000,1000) with: spdiagm(1000,1000, => Bin), i] for i = 1:length(d)].) D diag (v) returns a square diagonal matrix with vector v as the main diagonal. You would call spdiagm from the SparseArrays stdlib, e.g.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |