Answered
Cannot use find() inorder to find the index of a time in datetime array
Because you have sub-second precision in "t.a", t=load('time.mat'); t.a(end) seconds( t.a(end) - datetime('02-Dec-2014 07:05:...

4 years ago | 0

| accepted

Answered
FFT of Gaussian filter in 1D
sigma = 3.76e-6; u=0; %sampling parameters dt=sigma/30;5 %time sampling interval df=1/sigma/30; %frequency ...

4 years ago | 1

| accepted

Answered
How can i use elements with equal indexes?
problem.Constraints.diagcon=diag(x)*M-y>=0;

4 years ago | 0

| accepted

Answered
problem based approach- script running but does not gives a solution
There is only one objective, and two constraints so far and they all are linear. When i write my objective function it forces me...

4 years ago | 0

Answered
Getting mutliple lines into a legend from a for loop that provides different values
lgd = legend('2\gamma='+string(2*[0,0.5,1.5]));

4 years ago | 0

Answered
How to create new structure with each for loop?
if numel(start)==numel(stop) N=numel(start); clear Cook for k=N:-1:1 j=start(k):st...

4 years ago | 0

| accepted

Answered
Subclass of Built-in Type Does Not Properly Call Subref / Broken Indexing
subsref is not called by indexing expressions made within methods of the class. Otherwise, any indexing operations made within s...

4 years ago | 0

Answered
Classification of variables in parfor-Loop
N=numel(Pperp); M=numel(Ppara); V=zeros(N*M,numel(tau));% parfor j_G=1:N*M %rest of code V(j_G,...

4 years ago | 0

Answered
Very small feasibility value but very large first-order optimality value
That can happen if your objective function or constraints are not continuously differentiable, e.g., fmincon(@(x)sqrt(abs(x)),1...

4 years ago | 0

Answered
Border detection out of regular shape
load data_points data0=data; shp=alphaShape(data,0.9); [~,V]=boundaryFacets(shp); shp=polyshape(V,'Simplify',true); ...

4 years ago | 1

| accepted

Answered
polynomial help, is it to simply just use polyfit? I cant figure it out, I don't use matlab regularly
Yes, you could do most of it with polyfit.

4 years ago | 0

Answered
Polygon Expansion within Bounding Box
You might be able to use polybuffer() or scale() to expand the polygons together with intersect() to detect illegal intersection...

4 years ago | 0

Answered
Draw polygon around grid points
small_dots = [2.1250 52.6250 2.1250 52.8750 2.1250 53.1250 2.3750 52.3750 2.3750 52.6250 2.37...

4 years ago | 0

| accepted

Answered
Multiplying each column with a corresponding row value
A= [ 1 2 3 4 5] B= [1 2 3 4 5; 6 7 8 9 10; 1 1 2 3 1] C= A.*B

4 years ago | 0

| accepted

Answered
fzero solver within a for loop stops working at a certain step
I am not sure why you are using fzero. It looks like the root can be solved explicitly for x2. In any case, you can more easil...

4 years ago | 0

Answered
How would I prevent access to classes that shouldn't be publicly available in my toolkit?
You cannot truly hide the class, but you can have its constructor raise an error when someone tries to invoke it from outside yo...

4 years ago | 0

Answered
Dot product of tensor
Ar=reshape(A,[],3); Br=reshape(B,[],3); C=reshape( Ar*Br.' ,ma,na,mb,nb);

4 years ago | 0

Answered
tall array within a parfor?
You've generated idx in a way that doesn't have a simple dependence on the loop variable. This warning is not present if you are...

4 years ago | 1

| accepted

Poll


When I receive error messages in MATLAB, I understand them

4 years ago | 806 votes | 2 comments

Answered
Eigenvalue problem on non-Hermitian matrix
You said it yourself - the matrix is not Hermitian so there is no reason to expect inv(V)=W'. There is no reason even to expect ...

4 years ago | 0

Answered
Zero Pad My FFT Signal and Window
The zero-padding is fine. The way you set up your frequency axis, I'm a little unsure about. N=numel(FTSignal); NormalizedAx...

4 years ago | 0

Answered
How to resize a specific part of an image?
One way would be to perform an erosion using bwlerode (downloadable from here) load Image B=bwlerode(A,3,strel('disk',8)); ...

4 years ago | 0

Answered
Ax = 0 with 2 values of x known
b=-A(:,[1,end])*[xInitial;xFinal]; x=A(:,2:end-1)\b; x=[xInitial, x', xFinal]';

4 years ago | 0

Answered
Fitting a fourth order polynomial
You can use bounds to force the unwanted coefficients to zero. lb=[-inf,0,0,0,-inf]; fitobject = fit(x,y, 'poly4','Lower',l...

4 years ago | 0

| accepted

Answered
lsqnonlin data plotting and verification
If you use lsqcurvefit instead of lsqnonlin, any of the examples here, https://www.mathworks.com/help/optim/ug/lsqcurvefit.html...

4 years ago | 0

Poll


What is your main tool or approach for debugging MATLAB code?

4 years ago | 2506 votes | 10 comments

Answered
Problem with Linear inequality constraints
sum(over j)(xij)<=1 for each i This constraint can be written, x=rand(36); [m,n]=size(x); A=kron(ones(1,n),speye(m)); b=o...

4 years ago | 0

| accepted

Answered
How do you include a figure caption below a graph?
With the text() command you can position text anywhere in or around the axes that you wish.

4 years ago | 0

Answered
Regarding the differentiation of function
x = -10:0.1:10; y = [1 6 0.03 0.08 10]'; A = 23 * (atan((0.005 + y)./x.^2)); B = diff(A,1,2)/0.1; plot(x(1:end-1),B')

4 years ago | 0

| accepted

Load more