Answered
Created a class fucntion but I am not able to find output for certain conditions even though the value exists.
Tsk, tsk. You should know better than to test for exact equality with floating point values. >> obj.energy(591) ans = ...

4 years ago | 0

| accepted

Answered
Is there something similar as splitapply that works on a data table instead just on one value?
Tex=varfun(@(x){table2array(x)},tex,'InputVariables','Data'); out = varfun(@(z)max(cell2mat(z)), Tex,'InputVariables','Data',...

4 years ago | 0

| accepted

Answered
Arrow between several points
It might be easier just to use quiver(). h=plot(2:6,'o'); axis equal [X,Y]=deal(h.XData, h.YData); q=(1:0.5:numel(X))'; X=...

4 years ago | 0

Answered
array operation in matlab
a={'hi' 'lo' 'hi'}; b={'lo' 'hi' 'hi'}; nnz(string(a)=="hi" & string(b)=="hi")

4 years ago | 0

| accepted

Answered
Combining function parameters in to a single vector to solve with Lsqcurvfit / Lsqnonlin
One way, fun=@(x,w) fun(x(1),x(2),x(3),x(4),w);

4 years ago | 1

Answered
How to append 2 tables with different columns
Use outerjoin(). T1=table(('ABC')',[1,2,3]'); T2=table(('DEF')',[1,2,3]'+3,'Var',{'Var1','Var3'}); outerjoin(T1,T2,'MergeKe...

4 years ago | 0

| accepted

Answered
How to find the best circular fit for an irregular shape and define an average radious for it. The Goal is to define a fix distance from the weighed center and extract the ave
You can use circularFit(), available at https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-tools-for-fi...

4 years ago | 0

Answered
2-for loop iteration to output a matrix
A=[5 10 15 45]; %changing variables in the code B=[2 4]; %another changing variable for iteration D=A+B'

4 years ago | 1

| accepted

Answered
Fmincon giving error, citing initial objective function (which does satisfy constraints) and not working
I have already verified that Aeq*x0 = beq, so the initial objective function is right. The error message has nothing to do wit...

4 years ago | 0

Answered
How to use fsolve to optimize and minimize given parameters
Whether the final point is the same as the initial point or not, the message is telling you that the final point does solve the ...

4 years ago | 0

| accepted

Answered
How to rewrite the nested for loop to modify matrix elments when matrix size is huge
To vectorize this, you must vectorize f() and g(). Also, building a sparse matrix this way is a bad idea. You should use the sy...

4 years ago | 0

Answered
Arrow between several points
You can use the annotation() command.

4 years ago | 0

| accepted

Answered
How to select the first two (or first nth) rows of a matrix when the first and second elements of the rows always shows the same values fro more than two rows?
G=findgroups(A(:,1),A(:,2)); discard=cell2mat( splitapply(@(x){x(3:end,:)} , (1:numel(G))' ,G ) ); B=A; B(discard,:)=[];

4 years ago | 0

| accepted

Answered
I am using fsolve. "fsolve stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function to"
It means either that your equations have no solution, or that your initial guess isn't close enough to that solution.

4 years ago | 0

Answered
How to get rid of annoying extra white spaces on the margins when exporting surface plots to pdf?
Use export_fig instead, https://github.com/altmany/export_fig It will crop the borders by default.

4 years ago | 0

Answered
How do I map a 4x4 string matrix to a 4x4 set of edit fields?
You can compose a vector of handles hVector to your Edit Fields. Then, set(hVector,{'String'},cellstr(yourStrings))

4 years ago | 0

Answered
How to find out the coordinates of the rectangles through which a straight line passes?
Seems like a direct application of, [N,Zedges,Yedges, binZ, binY] = histcounts2(Z,Y,Zedges,Yedges)

4 years ago | 0

Answered
require subclasses to support the same number of input and output arguments as the abstract method of their super class
In the base class constructor, you can check the function signature, like in this example: classdef myclass methods ...

4 years ago | 0

| accepted

Answered
Defining structure as a property of a class
Perhaps as follows? classdef CartPole %CARTPOLE Summary of this class goes here % Detailed explanation goes here ...

4 years ago | 0

| accepted

Answered
3-d order derivative
You could try diff(x,3)

4 years ago | 0

Answered
Optimise a reference that cuts my curve into 2 equal sections
%t= time, X=consumption, x=unknown midline tc=t-t(1); Xc=cumtrapz(t,X); x=optimvar('x'); sol=solve( optimproble...

4 years ago | 0

| accepted

Answered
How to save mat file from specific index
My algo takes each frame seperatly thats why That does not disqualify keeping them all in a common .mat file. You can use matfi...

4 years ago | 0

Answered
deleting n entries in matlab
a=[1 nan 4 nan 4 3 ]; a=a(~isnan(a))

4 years ago | 0

| accepted

Answered
non zero elements in an array
If a are always integers, a = [1 2 4 5 3 0 0 8 0]; a=(a>=2)

4 years ago | 0

Answered
How to plot unsolvable equation
fcn=@(x,y) y .* sin( y ) - x .* sin( x ); fimplicit(fcn)

4 years ago | 1

Answered
Object Oriented Programming: How to create a child class that gives two parameters for working of parent class in Matlab?
I had to make a number of changes to your code (see attached). However, once you've implemented the classes this way, you can do...

4 years ago | 0

| accepted

Answered
Can't integrate exponential function
%syms x - doesn't belong here myFunc = @(x) (exp(x)./x); %use ./ y = integral(myFunc,3.5,4.5)

4 years ago | 0

| accepted

Answered
Fitting a curve as defined by a file, for the integral value
Your Fitfile doesn't match the model previously described y = a*exp(-x./b)+c so I'm not sure which one is supposed to be correct...

4 years ago | 0

Answered
how to scale fft?
The DFT is a tool for computing several other theoretical transforms. It can be used to compute a Discrete Fourier Series, whic...

4 years ago | 0

| accepted

Answered
Finding neighbors in pages of very large 3D matrix
kernels={[1 1], [1;1], eye(2), fliplr(eye(2))}; counts=0; for i=1:4 map = convn(binary_3D,kernels{i},'valid')==2; ...

4 years ago | 0

Load more