Answered
Create unit vector for every vector in 3d array
normalize(yourArray,1,'n')

3 years ago | 0

| accepted

Answered
Create multidimensional rotation matrix
howbig=541; [aclon,aclat]=deal(rand(howbig,1)); %fake input data aclon=reshape(aclon,1,1,[]); aclat=reshape(aclat,1,1,[]...

3 years ago | 0

| accepted

Answered
How to added a attention layer in a CNN model in MatLab?
This looks relevant: https://www.mathworks.com/matlabcentral/answers/1743390-how-to-create-an-attention-layer-for-deep-learning...

3 years ago | 0

Answered
How to conditionally define a learnable property?
If you really must have a layer with different properties, based on a conditional flag setting, it would probably be better to ...

3 years ago | 1

Answered
Combine 3 fig. graphs in one plot to compare each other
Suppose ax is a vector of axes handles to all of your separate plots. Then, you could re-parent the axes to a TiledChartLayout i...

3 years ago | 0

| accepted

Answered
Optimization problem with cost function containing definite integral with one endpoint being part of the solution vector
You've written your functions in terms of 2 arguments (p,S), whereas fseminf expects all the unknowns to be part of one argument...

3 years ago | 0

| accepted

Answered
Tensor creation like "pageTensorprod"?
Is there an easier way? The resulting code lacks readability in my opinion. Probably not, but regardless, readability shouldn't...

3 years ago | 0

| accepted

Answered
Construct a permutation matrix from two vectors
a = [1 ; 2 ; 3]; b = [4 ; 5 ; 6]; [B,A]=ndgrid(b,a); c=[A(:),B(:)]

3 years ago | 0

| accepted

Answered
How to conditionally define a learnable property?
You could also set the learning rate of a particular parameter to zero, based on your conditional flag, https://www.mathworks.c...

3 years ago | 0

Answered
How to conditionally define a learnable property?
An indirect solution would be to have an additional property Wknown that lets you provide an over-riding prior value for a parti...

3 years ago | 0

Answered
Merge the four faces belonging to a tetrahedron
The process you've described doesn't uniquely determine what the new tetrahedron decomposition should be. However, you could use...

3 years ago | 0

| accepted

Answered
Several nested for-loops within parfor-loop variable indexing
If you just remove the line, saveVariablesFunc(savedVar) form the loop it will work, after you also fix the defintion of jn....

3 years ago | 1

| accepted

Answered
plotting functions over domain
fsurf(@(x,y) (x.^2 + 3*y.^2).*exp(1 - x.^2 - y.^2), [-1,1],ShowContours='on');

3 years ago | 0

| accepted

Answered
Trying to rotate a shape made with drawpolygon
Here's a solution that you can tweak to your liking. As demonstrated below, the code creates a red rotatable rectangle around th...

3 years ago | 0

| accepted

Answered
How to compare a matrix of values to all values within an array without loops
A = [1 2 4; 5 6 9;12 13 15]; grayLevelZeros = setdiff(min(A(:)):max(A(:)),unique(A))-1; grayLevelZerosFix = discretize(A,...

3 years ago | 0

| accepted

Answered
Subsetting a row of a matrix according to conditions in another row
y( ismember(t, subset) );

3 years ago | 1

| accepted

Answered
left and right sides have a different number of elements
A = [10 -2 -5 30; -2 15 -5 -5; -5 -5 14 25]; C = [2 ; 1 ; 3]; Error = 100; Thr = 1; Iter = 0; x1 = C(1,1); x2 = C(2,1)...

3 years ago | 0

Answered
When defining an anonymous function, how do I utilize cell indexing of an intermediate function?
Here's one way. Ultimately, though, it probably makes more sense to be using non-anonymous functions. epsin=@(n) wrapper(n, eps...

3 years ago | 0

| accepted

Answered
Populating off-diagonal blocks of diagonal matrix and making it sparse
Perhaps as below. Note that the first 3 lines are just fixed precomputations. n=2; p=3; T=5; Matrix=kron(eye(n),eye(T)); [L,...

3 years ago | 0

| accepted

Answered
Hi , I get the following error using intlinprog : The number of columns in Aeq must be the same as the length of f. anyway to overcome it?Error using intlinprog (line 135)
You have 3 unknown variables, but your Aeq matrix has only 1 column. That makes it impossible for intlinprog to form the matrix-...

3 years ago | 0

Answered
Does Matlab provide any tools to understand the contents in an image and describe it using words?
You could start with this example, https://www.mathworks.com/help/deeplearning/ug/image-captioning-using-attention.html#ImageCa...

3 years ago | 0

Answered
Anonymous function only returns single answer
Use the elementwise division operator ./ x=pi:pi/100:2*pi; y=x.^2; z = @(a,b) ((sin(a)+cos(b))./((a.^2)+(b.^2))); b = z(x,y)...

3 years ago | 1

| accepted

Answered
How to implement the Gaussian radial basis function in MATLAB ?
If you have the Statistics Toolbox, you can avoid a loop by using pdist2 Lt = 10; p = rand(Lt,4); sigma = 1.0; K=exp(-pdis...

3 years ago | 0

Answered
How do I plot a prod function in MATLAB?
fun=@(t) abs(t-5)<=1/2; fplot(fun,[1,10]); axis padded

3 years ago | 0

| accepted

Answered
Concise way to remove columns of a matrix with at least 2 repeating values in separate rows
One possibilty, A =[ 2 8 1 8 2 3 1 7 5 4 5 4 2 6 3 1 ...

3 years ago | 0

| accepted

Answered
How to evaluate individual once at a time when using GA with parallel processing?
The objective function will always evaluate one point at a time unless you are using the UseVectorized option. As for your scre...

3 years ago | 0

| accepted

Answered
lsqnonlin initial conditions (transcendental equation)
You can split the model function into real and imaginary parts, func=@(a) [real(func(a)); imag(func(a))]; [k,resnorm,residua...

3 years ago | 1

| accepted

Answered
Why does fmincon using the sqp algorithm need a full matrix to specify linear constraints?
Probably because the SQP algorithm must extract subsets of rows of the constraint matrice quite often. This can be much faster f...

3 years ago | 1

| accepted

Answered
How can I ort elements of a column in a matrix using elements of another column in another matrix
subset=[1,3] %The vector of IDs with positive y-intercept idx=ismember(Matrix1(:,3),subset); Matrix1=Matrix1(idx,:);

3 years ago | 0

| accepted

Load more