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

Answered
solve non-linear equation
You can solve for x=e^(-z) using roots. Then use z=-log(x). Example: z=2.4; pho=2; L=2; G = exp(-z) + pho*exp(L-2*z); ...

3 years ago | 0

Answered
How to build a function fun that takes as input the matrix A and as output provides the matrix B which is produced out of A in the following ways.
You can use this FEX download, https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transposition-permutation-and-...

3 years ago | 0

Answered
How to get gradient data from non-linear 2D plot
Yes, you can use the diff or gradient command.

3 years ago | 0

Answered
When plot graph vertex labels cut the edges, how to avoid it?
You can remove the node labels as follows: h=plot(graph(bucky)); h.NodeLabel={};

3 years ago | 0

Answered
How to get pixel value inside a circle
drawcircle() returns an object with a createMask method. Using the mask produced by createMask(), you can do, mean(yourImage(ma...

3 years ago | 0

| accepted

Answered
Find the centre and the radius of the circle or ellipse
You can download this, https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-tools-for-fitting-conics-and-...

3 years ago | 0

| accepted

Answered
Data show one value why all values not displying?
That's not unthinkable, if the points in the plot were generated one at a time and discarded: for fid=linspace(0.01,0.1185,10) ...

3 years ago | 1

Answered
plot sfit shows an offset between data and the fit but the residuals are very small.
One thing that seems to be creating problems is that your model function returns different results depending on whether the (x,...

3 years ago | 1

| accepted

Answered
How to append a large number of cell arrays vertically?
s=dir('stations_*.mat'); CellList=cellfun(@(z) load(z).stations1,{s.name},'uni',0); result=vertcat(CellList{:})

3 years ago | 1

| accepted

Answered
Removing a part of curve
I'll demonstrate a technique using a simpler example, since only you know the mathematical meaning of the region to be excluded ...

3 years ago | 0

Answered
Get the last rows of tables inside a cell array
There is no way to avoid the slow speed of a loop when dealing with cell arrays. Cell arrays are not meant to be fast. However, ...

3 years ago | 0

Answered
Why do I get 'Array indices must be positive or logical values' in symsum function?
The error is because you appear to be indexing P with a non-integer. Did you mean to write, sin(n*P*(1-y/h)) ?

3 years ago | 0

Answered
Calculate the conrast by the difference between the highest and lowest intensity value
You could use medfilt2 or medfilt3 to get rid of the outliers. You could then use discretize to bin the data into bins of width ...

3 years ago | 0

| accepted

Answered
Confidence and prediction bands using nlsqcurvefit
Covariance methods are not valid when you have parameter bound constraints. Since it's not a time-consuming fit, I would just us...

3 years ago | 0

| accepted

Load more